4 releases (2 stable)

1.1.0 Nov 29, 2020
1.0.0 Nov 27, 2020
0.1.1 Nov 26, 2020
0.1.0 Nov 26, 2020

#1195 in Parser implementations

Download history 7069/week @ 2023-12-08 6562/week @ 2023-12-15 5609/week @ 2023-12-22 4429/week @ 2023-12-29 6489/week @ 2024-01-05 5747/week @ 2024-01-12 6312/week @ 2024-01-19 5511/week @ 2024-01-26 6059/week @ 2024-02-02 7287/week @ 2024-02-09 7984/week @ 2024-02-16 7314/week @ 2024-02-23 6932/week @ 2024-03-01 7832/week @ 2024-03-08 7826/week @ 2024-03-15 6749/week @ 2024-03-22

30,303 downloads per month
Used in 11 crates (8 directly)

MIT/Apache

29KB
522 lines

Coverage Tests

Rustc Semver

This crate provides a minimalistic parser for Rust versions.

Description

The parser will only accept Versions in the form

<major>.<minor>.<patch>

and 3 special versions:

  • 1.0.0-alpha
  • 1.0.0-alpha.2
  • 1.0.0-beta

This covers every version of rustc that were released to date.

Usage

There are 2 functions to create a RustcVersion:

  1. const RustcVersion::new(u32, u32, u32): This is mainly used to create constants
  2. RustcVersion::parse(&str): Usually you want to parse a version with this function

If you have a RustcVersion you can compare them, like you would expect:

assert!(RustcVersion::parse("1.42.0")? < RustcVersion::parse("1.43")?);

If you want to check whether one version meets another version according to the Caret Requirements, there is the method RustcVersion::meets:

assert!(RustcVersion::new(1, 48, 0).meets(RustcVersion::parse("1.42")?));

Code of Conduct

This repository adopts the Contributor Covenant Code of Conduct

License

Copyright 2020 Philipp Krones

Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. Files in the project may not be copied, modified, or distributed except according to those terms.

No runtime deps