semver icon indicating copy to clipboard operation
semver copied to clipboard

PartialVersion parsing support

Open Benjscho opened this issue 1 year ago • 2 comments

Creating this issue to discuss about for PartialVersion parsing. Currently Version::parse only supports parsing full versions (i.e., with at least a major, minor, and a patch).

Would you be against adding support for PartialVersion parsing, e.g., in the same manner that Cargo handles partial versions? This would involve adding a new struct PartialVersion, that supports parsing incomplete versions, and implementing impl From<semver::PartialVersion> for Version

I'd be happy to submit a PR to add the struct & parsing if there's interest.

Benjscho avatar Oct 29 '24 17:10 Benjscho

I am open to it, but I have seen different projects expect different semantics from a "partial version". I would need to be shown that the behavior you want in this crate is widely applicable. For example I am not sure there is consensus about whether a partial version is supposed to represent build metadata.

dtolnay avatar Oct 29 '24 19:10 dtolnay

I'd propose following the implementation in Cargo, where if a PartialVersion can be completely parsed as a Version then it can contain build metadata, e.g., 0.1.0+build parses into a PartialVersion which contains build metadata, but 0.1+build would fail with a build metadata error.

Benjscho avatar Oct 29 '24 20:10 Benjscho