Feature Request: Compatibility with PubGrub::VersionSet
- Dominant language
- Rust
- Stars
- 669
- Forks
- 144
- PR merge metrics
- No merged PRs in 30d
Description
[pubgrub-rs](https://github.com/pubgrub-rs/pubgrub) 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:
```rs
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 Vecs
/// 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.