pubgrub-rs provides implementation for dependency tree resolution. I'm trying to integrate semver with pubgrub in my project.
I want to implement the pubgrub::VersionSet trait for semver::VersionReq.
Initially I thought of creating a wrapper type and implementing the trait for that, but it needs the following methods:
pub trait VersionSet: Debug + Display + Clone + Eq {
type V: Debug + Display + Clone + Ord;
// Constructors
/// An empty set containing no version.
fn empty() -> Self; // Easy enough to handle in the wrapper
/// A set containing only the given version.
fn singleton(v: Self::V) -> Self; // trivial using the Op::Exact comparator
// Operations
/// The set of all version that are not in this set.
fn complement(&self) -> Self; // <-------------------- This is difficult
/// The set of all versions that are in both sets.
fn intersection(&self, other: &Self) -> Self; // Essentially concatenation of the two Vec<Comparator>s
/// Whether the version is part of this set.
fn contains(&self, v: &Self::V) -> bool; // Trivial using VersionReq::matches
}
All of the pubgrub::VersionSet trait members are easy enough to implement apart from the complement.
One approach I thought of was to take the individual Comparators and negate them as required. but I'd have to implement my own version of semver::eval::matches_comparator since that function is private to the semver crate.
Do you think there is value in having this functionality as part of semver. Otherwise, would you be open to making the eval::matches_comparator function public so I can reuse that functionality.
pubgrub-rs provides implementation for dependency tree resolution. I'm trying to integrate semver with pubgrub in my project.
I want to implement the
pubgrub::VersionSettrait forsemver::VersionReq.Initially I thought of creating a wrapper type and implementing the trait for that, but it needs the following methods:
All of the
pubgrub::VersionSettrait members are easy enough to implement apart from thecomplement.One approach I thought of was to take the individual
Comparatorsand negate them as required. but I'd have to implement my own version ofsemver::eval::matches_comparatorsince that function is private to thesemvercrate.Do you think there is value in having this functionality as part of
semver. Otherwise, would you be open to making theeval::matches_comparatorfunction public so I can reuse that functionality.