Skip to content

Commit

Permalink
Get rid of the boxed iterator returned from query in favor of impl It…
Browse files Browse the repository at this point in the history
…erator
  • Loading branch information
tgecho committed Dec 29, 2023
1 parent acedb4f commit 48dda87
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: 1.70.0
toolchain: 1.75.0
override: true
- name: Build
run: cargo build --verbose
Expand Down
2 changes: 1 addition & 1 deletion canrun/Cargo.toml
Expand Up @@ -10,7 +10,7 @@ categories = ["algorithms", "mathematics"]
keywords = ["logic", "dsl", "kanren"]
license = "MIT/Apache-2.0"
edition = "2021"
rust-version = "1.70.0"
rust-version = "1.75.0"

[dependencies]
im-rc = "15.1.0"
Expand Down
8 changes: 4 additions & 4 deletions canrun/src/core/query.rs
Expand Up @@ -24,7 +24,7 @@ A blanket impl covers anything that implements [`StateIterator`], so many
types including [`Goal`](crate::goals) and [`State`](crate::State) are
queryable.
*/
pub trait Query<'a> {
pub trait Query {
/**
Get [reified](crate::core::Reify) results from things that can produce
[`StateIter`](crate::core::StateIter)s.
Expand Down Expand Up @@ -57,11 +57,11 @@ pub trait Query<'a> {
assert_eq!(result, vec![1])
```
*/
fn query<Q: Reify + 'a>(self, query: Q) -> Box<dyn Iterator<Item = Q::Reified> + 'a>;
fn query<Q: Reify>(self, query: Q) -> impl Iterator<Item = Q::Reified>;
}

impl<'a, S: StateIterator + 'a> Query<'a> for S {
fn query<Q: Reify + 'a>(self, query: Q) -> Box<dyn Iterator<Item = Q::Reified> + 'a> {
impl<S: StateIterator> Query for S {
fn query<Q: Reify>(self, query: Q) -> impl Iterator<Item = Q::Reified> {
Box::new(
self.into_states()
.filter_map(move |s| query.reify_in(&s.ready()?)),
Expand Down
2 changes: 1 addition & 1 deletion examples/Cargo.toml
Expand Up @@ -7,7 +7,7 @@ repository = "https://github.com/tgecho/canrun_rs"
documentation = "https://docs.rs/crate/canrun_collections"
license = "MIT/Apache-2.0"
edition = "2021"
rust-version = "1.70.0"
rust-version = "1.75.0"

[dependencies]
canrun = { path = "../canrun"}
Expand Down

0 comments on commit 48dda87

Please sign in to comment.