Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
<!-- next-header -->
## [Unreleased] - ReleaseDate

- Make `BoxPredicate::find_case` use the inner `find_case` implementation

## [3.1.3] - 2024-12-19

### Features
Expand Down
17 changes: 15 additions & 2 deletions src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use std::fmt;

use crate::reflection;
use crate::utils;
use crate::Predicate;

/// `Predicate` that wraps another `Predicate` as a trait object, allowing
Expand Down Expand Up @@ -73,7 +72,7 @@ where
}

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
self.0.find_case(expected, variable)
}
}

Expand Down Expand Up @@ -125,4 +124,18 @@ mod test {
let p = predicate::always().boxed();
p.eval("4");
}

#[test]
fn boxed_find_case() {
let p1 = predicate::gt(5);
let p2 = p1.boxed();
match (p1.find_case(false, &4), p2.find_case(false, &4)) {
(Some(c1), Some(c2)) => {
assert_eq!(format!("{c1:?}"), format!("{c2:?}"));
}
_ => {
panic!();
}
}
}
}