EqPredicate stores T and its eval takes a &T. But what about Vec/slice, String/str, and PathBuf/path?
Exploration Summary
After making Predicate use generics rather than associated types (see #29)
Dead ends
Predicate { eval<I: AsRef<Item>>(&self, item: I) }: not object-safe which means we can't Box<Predicate> or &Predicate.
Predicate { eval(&self, item: Item) } (ie Item=&str rather than Item=str): violates borrow checker in boolean predicates
- Above with
Item: Copy: Lifetime issues (branch)
impl Predicate<AsRef<T>> for EqPredicate<T>: No AsRef implemented for numeric types
impl Predicate<Borrow<T>> for EqPredicate<T>: Sized issues (branch)
Options:
EqPredicatestoresTand itsevaltakes a&T. But what aboutVec/slice,String/str, andPathBuf/path?Exploration Summary
After making
Predicateuse generics rather than associated types (see #29)Dead ends
Predicate { eval<I: AsRef<Item>>(&self, item: I) }: not object-safe which means we can'tBox<Predicate>or&Predicate.Predicate { eval(&self, item: Item) }(ieItem=&strrather thanItem=str): violates borrow checker in boolean predicatesItem: Copy: Lifetime issues (branch)impl Predicate<AsRef<T>> for EqPredicate<T>: No AsRef implemented for numeric typesimpl Predicate<Borrow<T>> for EqPredicate<T>:Sizedissues (branch)Options:
AsRefadapter