Skip to content

API doesn't work well with distinct owned / ref types #20

@epage

Description

@epage

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:

  • Create an AsRef adapter

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions