Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support introspection into a VersionReq #59

Closed
sfackler opened this issue Nov 10, 2015 · 9 comments
Closed

Support introspection into a VersionReq #59

sfackler opened this issue Nov 10, 2015 · 9 comments
Milestone

Comments

@sfackler
Copy link
Contributor

It'd be nice to be able to look directly at the set of constraints in a VersionReq. For example, the implementation of RFC 1241 wants to check if a VersionReq corresponds to a wildcard but the implementation is forced to just compare for equality agaist VersionReq::parse("*").unwrap(): https://github.com/rust-lang/cargo/pull/2005/files#diff-e23c793746a7be78139a4e37509a74acR112

@anguslees
Copy link

+1. I want to parse a semver and express the implied min/max constraints in a similar constraint syntax (Debian packaging metadata). It'd be real nice if VersionReq predicates were exposed in some way to prevent me having to duplicate all that parsing logic.

@joshtriplett
Copy link

It looks like semver-parser provides the ability to introspect into its version of VersionReq, but semver has its own version of VersionReq that doesn't allow introspection.

Could semver just use the types from semver-parser, rather than converting to its own?

@steveklabnik
Copy link
Contributor

Could semver just use the types from semver-parser, rather than converting to its own?

I would say yes, but in a slightly different way: they should still convert over, but we should evolve VersionReq to be more useful.

Now that we've fully converted over, I want to take a hard look at the whole interface, looking towards a 1.0. These kinds of changes are the things I might want to make.

@joshtriplett
Copy link

@steveklabnik Why the separate types and conversion between them?

@steveklabnik
Copy link
Contributor

They're two separate crates, the conversion means that I don't leak the specific semver-parser into semver's external API.

@joshtriplett
Copy link

Is there a strong reason to keep them separate rather than unifying them?

@steveklabnik
Copy link
Contributor

I like small crates, and keeping concerns separate. One crate for one thing; one handles the conversions, the other has all of the logic for comparisons, etc. it feels like the split between -sys and not to me. Plus, there could be other back ends: maybe that nom parser I tried would work better, or LALRPOP.

But! Part of that is the beauty of < 1.0: I'm not actually sure. We'll see.

On Aug 8, 2016, 19:23 -0400, Josh Triplett notifications@github.com, wrote:

Is there a strong reason to keep them separate rather than unifying them?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub (#59 (comment)), or mute the thread (https://github.com/notifications/unsubscribe-auth/AABsio9cOyLsza_0So_cP-amaGhkpa0Hks5qd7pbgaJpZM4GfolK).

@steveklabnik steveklabnik added this to the 1.0 milestone Aug 10, 2016
@opilar
Copy link
Contributor

opilar commented Sep 24, 2017

I don't know how it could be implemented: for now VersionReq is just a bunch of Predicate's. For me it's not clear how to get a min and max constrains.
How can VersionReq be exposed actually?

@dtolnay
Copy link
Owner

dtolnay commented May 25, 2021

This is now available in 1.0.0. https://docs.rs/semver/1.0.0-rc.1/semver/struct.VersionReq.html

@dtolnay dtolnay closed this as completed May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants