From 7cd735b9ed1e43168fc9cbeceafa065c8327ce39 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Tue, 17 Dec 2024 19:40:57 +1100 Subject: [PATCH] feat: Implement PredicateBoxExt for `?Sized` In particular, this makes `predicate::str::contains(...).boxed()` work. --- CHANGELOG.md | 5 +++++ src/boxed.rs | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec90235..c27e58f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [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 diff --git a/src/boxed.rs b/src/boxed.rs index 55caac3..2b96e0c 100644 --- a/src/boxed.rs +++ b/src/boxed.rs @@ -114,4 +114,15 @@ where } } -impl PredicateBoxExt for P where P: Predicate {} +impl PredicateBoxExt for P where P: Predicate {} + +#[cfg(test)] +mod test { + use crate::prelude::*; + + #[test] + fn unsized_boxed() { + let p = predicate::always().boxed(); + p.eval("4"); + } +}