]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | [![Coverage](https://img.shields.io/badge/dynamic/json?color=brightgreen&label=coverage&query=%24.data%5B0%5D.totals.lines.percent&suffix=%25&url=https%3A%2F%2Fraw.githubusercontent.com%2Fflip1995%2Frustc-semver%2Fgh-pages%2Fcov.json)](https://flip1995.github.io/rustc-semver/) |
2 | [![Tests](https://github.com/flip1995/rustc-semver/workflows/Tests/badge.svg)](https://github.com/flip1995/rustc-semver/actions?query=branch%3Amaster+event%3Apush+workflow%3ATests) | |
3 | ||
4 | # Rustc Semver | |
5 | ||
6 | This crate provides a minimalistic parser for Rust versions. | |
7 | ||
8 | ## Description | |
9 | ||
10 | The parser will only accept Versions in the form | |
11 | ||
12 | ```text | |
13 | <major>.<minor>.<patch> | |
14 | ``` | |
15 | ||
16 | and 3 special versions: | |
17 | ||
18 | - `1.0.0-alpha` | |
19 | - `1.0.0-alpha.2` | |
20 | - `1.0.0-beta` | |
21 | ||
22 | This covers every version of `rustc` that were released to date. | |
23 | ||
24 | ## Usage | |
25 | ||
26 | There are 2 functions to create a `RustcVersion`: | |
27 | ||
28 | 1. `const RustcVersion::new(u32, u32, u32)`: This is mainly used to create | |
29 | constants | |
30 | 2. `RustcVersion::parse(&str)`: Usually you want to parse a version with this | |
31 | function | |
32 | ||
33 | If you have a `RustcVersion` you can compare them, like you would expect: | |
34 | ||
35 | ```rust | |
36 | assert!(RustcVersion::parse("1.42.0")? < RustcVersion::parse("1.43")?); | |
37 | ``` | |
38 | ||
39 | If you want to check whether one version meets another version according to the | |
40 | [Caret Requirements], there is the method `RustcVersion::meets`: | |
41 | ||
42 | ```rust | |
43 | assert!(RustcVersion::new(1, 48, 0).meets(RustcVersion::parse("1.42")?)); | |
44 | ``` | |
45 | ||
46 | [Caret Requirements]: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#caret-requirements | |
47 | ||
48 | ## Code of Conduct | |
49 | ||
50 | This repository adopts the [Contributor Covenant Code of | |
51 | Conduct](https://www.contributor-covenant.org/version/1/4/code-of-conduct/) | |
52 | ||
53 | ## License | |
54 | ||
55 | Copyright 2020 Philipp Krones | |
56 | ||
57 | Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
58 | https://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or | |
59 | https://opensource.org/licenses/MIT>, at your option. Files in the project may | |
60 | not be copied, modified, or distributed except according to those terms. |