diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1794592..8cc36c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,3 +21,5 @@ jobs: run: RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --workspace --document-private-items --examples --bins --lib - name: Check formatting run: cargo fmt --check + - name: Check clippy + run: cargo clippy diff --git a/CHANGELOG.md b/CHANGELOG.md index b67ac99..17a18d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,20 @@ # Changelog -## 0.3 - 2024-11-24 +## v0.4.0 - 2024-12-01 + +Many thanks to [@dcz-self](https://github.com/dcz-self) for a bunch of contributions! + +New features: +- The textual language now supports line comments with `%` ([#26](https://github.com/fatho/logru/pull/26)) +- `VarScope`s now provide additional functions to inspect the variables in the scope ([#23](https://github.com/fatho/logru/pull/23)) +- `TextualUniverse` is now captured immutably by prepared queries, so that multiple queries can be run concurrently against the universe ([#27](https://github.com/fatho/logru/pull/27)) + +Breaking changes: +- `SolutionIter` now returns `Solution`s rather than `Vec<_>`s, making it easier to relate goal variables to solution terms ([#25](https://github.com/fatho/logru/pull/25)) +- The concrete symbol storage used by e.g. the parser and some resolvers is now abstracted behind a `SymbolStorage` trait (as part of the works for [#27](https://github.com/fatho/logru/pull/27)) + + +## v0.3.0 - 2024-11-24 New features: - Named variables and wildcards ([#14](https://github.com/fatho/logru/pull/14)) @@ -22,6 +36,7 @@ Bug fixes: - Occurs check did not follow bound variables (fixed in [#16](https://github.com/fatho/logru/pull/16)) -## 0.2 - 2021-10-13 + +## v0.2.0 - 2021-10-13 Initial release \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 77b1804..7a515db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -238,12 +238,12 @@ checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d" [[package]] name = "errno" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -327,16 +327,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -348,9 +349,9 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.164" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "433bfe06b8c75da9b2e3fbea6e5329ff87748f0b144ef75306e674c3f6f7c13f" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libredox" @@ -409,7 +410,7 @@ dependencies = [ [[package]] name = "logru" -version = "0.3.0" +version = "0.4.0" dependencies = [ "criterion", "ctrlc", @@ -711,9 +712,9 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "syn" -version = "2.0.89" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -762,9 +763,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -773,9 +774,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", @@ -784,9 +785,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", "valuable", @@ -805,9 +806,9 @@ dependencies = [ [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "nu-ansi-term", "sharded-slab", @@ -865,9 +866,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -876,9 +877,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", @@ -891,9 +892,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -901,9 +902,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", @@ -914,15 +915,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/Cargo.toml b/Cargo.toml index d75dbda..5b3ef29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "logru" -version = "0.3.0" +version = "0.4.0" description = "A small, embeddable and fast interpreter for a subset of Prolog." keywords = ["prolog", "logic-programming", "first-order-logic"] categories = ["compilers", "algorithms", "mathematics"] @@ -15,12 +15,12 @@ include = ["README.md", "testfiles/*", "**/*.rs", "Cargo.toml"] logos = "0.14.2" [dev-dependencies] -criterion = { version = "0.5.1", features = ["html_reports"] } -ctrlc = "3.4.5" -dirs = "5.0.1" -rustyline = "15.0.0" -tracing = "0.1.40" -tracing-subscriber = "0.3.18" +criterion = { version = "0.5", features = ["html_reports"] } +ctrlc = "3.4" +dirs = "5.0" +rustyline = "15.0" +tracing = "0.1" +tracing-subscriber = "0.3" [profile.release] debug = true diff --git a/examples/arithmetic.rs b/examples/arithmetic.rs index 78eeadc..4744034 100644 --- a/examples/arithmetic.rs +++ b/examples/arithmetic.rs @@ -17,7 +17,7 @@ fn main() { " ${} = {}", var.ord(), u.pretty() - .term_to_string(&term, query.query().scope.as_ref()) + .term_to_string(term, query.query().scope.as_ref()) ); } else { println!(""); diff --git a/examples/repl.rs b/examples/repl.rs index 88f2992..283ba3b 100644 --- a/examples/repl.rs +++ b/examples/repl.rs @@ -176,7 +176,7 @@ fn query(state: &mut AppState, args: &str) { state .universe .pretty() - .term_to_string(&term, query.query().scope.as_ref()) + .term_to_string(term, query.query().scope.as_ref()) ); } else { println!(""); diff --git a/src/search/test.rs b/src/search/test.rs index d1db314..58b9c69 100644 --- a/src/search/test.rs +++ b/src/search/test.rs @@ -246,7 +246,7 @@ fn cut() { .map(|var| { var.as_ref().map(|term| { tu.pretty() - .term_to_string(&term, query.query().scope.as_ref()) + .term_to_string(term, query.query().scope.as_ref()) }) }) .collect::>() diff --git a/src/textual/parser.rs b/src/textual/parser.rs index 65660f8..4ede81f 100644 --- a/src/textual/parser.rs +++ b/src/textual/parser.rs @@ -95,7 +95,7 @@ pub struct Parser { symbols: T, } -impl<'a, T: SymbolStorage> Parser { +impl Parser { pub fn new(symbols: T) -> Self { Self { symbols } } @@ -286,8 +286,8 @@ mod test { use crate::universe::{SymbolOverlay, SymbolStore}; fn query_roundtrip_test(input: &str) { - let mut ss = SymbolStore::new(); - let nu = SymbolOverlay::new(&mut ss); + let ss = SymbolStore::new(); + let nu = SymbolOverlay::new(&ss); let mut p = Parser::new(nu); let q = p.parse_query_str(input).unwrap(); diff --git a/src/universe.rs b/src/universe.rs index cba9d21..ecdedba 100644 --- a/src/universe.rs +++ b/src/universe.rs @@ -36,8 +36,8 @@ where T: SymbolStorage, { fn get_or_insert_named(&mut self, name: &str) -> Sym { - let this: &mut T = *self; // Specify the concrete type to call to avoid accidentally recursing back into this method and creating an infinite loop. - this.get_or_insert_named(name) + // The deref is important so that we call the impl for `T`, and not `Self`. + (*self).get_or_insert_named(name) } } @@ -122,7 +122,7 @@ impl Symbols for SymbolStore { } } -impl<'a> SymbolStorage for SymbolStore { +impl SymbolStorage for SymbolStore { /// Return the symbol associated with the name, or allocate a fresh ID and associate it with the /// given name. fn get_or_insert_named(&mut self, name: &str) -> Sym {