Skip to content

Commit

Permalink
feat: Implement PredicateBoxExt for ?Sized
Browse files Browse the repository at this point in the history
In particular, this makes `predicate::str::contains(...).boxed()` work.
  • Loading branch information
marienz committed Dec 19, 2024
1 parent 5bd6da7 commit 7cd735b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
<!-- next-header -->
## [Unreleased] - ReleaseDate

### Added

- The `boxed` function is now available for predicates with an `Item` type that
is not `Sized`.

## [3.1.2] - 2024-07-25

## [3.1.1] - 2024-07-25
Expand Down
13 changes: 12 additions & 1 deletion src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,15 @@ where
}
}

impl<P, Item> PredicateBoxExt<Item> for P where P: Predicate<Item> {}
impl<P, Item: ?Sized> PredicateBoxExt<Item> for P where P: Predicate<Item> {}

#[cfg(test)]
mod test {
use crate::prelude::*;

#[test]
fn unsized_boxed() {
let p = predicate::always().boxed();
p.eval("4");
}
}

0 comments on commit 7cd735b

Please sign in to comment.