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

How to access Range in VersionReq? #233

Closed
Shnatsel opened this issue May 7, 2021 · 2 comments
Closed

How to access Range in VersionReq? #233

Shnatsel opened this issue May 7, 2021 · 2 comments

Comments

@Shnatsel
Copy link

Shnatsel commented May 7, 2021

I have a use case where I need to transform a bunch of VersionReqs to ranges, so that a much simpler downstream matcher can then operate on ranges and find if a given version falls within a given range or not.

The problem is that the ranges field on VersionReq is private, along with the Range struct. I'm using a patched copy with those fields made public for prototyping, but I'd like to arrive to a long-term solution that does not require patching.

Should I open a pull request making Range a public struct? Or do you prefer to keep those fields that private, but uplift the entire range conversion logic into semver? Or is there some other approach that I should take?

For context, I just want to know the intervals, and semver's version selection logic around pre-releases would be actively harmful (see #172).

@Shnatsel
Copy link
Author

Shnatsel commented May 7, 2021

Turns out that making this field public and in any way useful requires exposing a lot of internals. My first thought was to serialize the list of ranges to string and use semver_parser to get it back as public structs, but I can't find a sane way to turn the constraints into strings that can be fed to semver_parser either.

@Shnatsel Shnatsel mentioned this issue May 18, 2021
2 tasks
@dtolnay
Copy link
Owner

dtolnay commented May 25, 2021

This is fixed 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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants