Debian Codegraph @

src/miniver.rs

raw symbols SCIP
1 use craterust-analyzer cargo notify-rust 4.18.0 crate/::errorrust-analyzer cargo notify-rust 4.18.0 error/::*;
2 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
3
4 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
5 pub struct Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version# {
6 pub majorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#major.: u64,
7 pub minorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#minor.: u64,
8 }
9
10 impl Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version# {
11 #[allow(dead_code)]
12 pub fn newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(major: u64, minor: u64) -> Selfrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version] {
13 Selfrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version] { majorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#major., minorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#minor. }
14 }
15 }
16
17 impl FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr# for Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version# {
18 type Errrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version][FromStr]Err# = Errorrust-analyzer cargo notify-rust 4.18.0 error/Error#;
19 fn from_strrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version][FromStr]from_str().(s: &str) -> Resultrust-analyzer cargo notify-rust 4.18.0 error/Result#<Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#> {
20 let vv = s.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('.').collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&str>>();
21 match (vv.firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().(), vv.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(1)) {
22 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(maj), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(min)) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version# {
23 majorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#major.: maj.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
24 minorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#minor.: min.parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
25 }),
26 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ErrorKindrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#::SpecVersionrust-analyzer cargo notify-rust 4.18.0 error/ErrorKind#SpecVersion#(s.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
27 }
28 }
29 }
30
31 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/;
32
33 impl PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd# for Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version# {
34 fn partial_cmprust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version][`PartialOrd<Self>`]partial_cmp().(&self, other: &Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#> {
35 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.cmprust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version][Ord]cmp().(other))
36 }
37 }
38
39 impl PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version# {
40 fn eqrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version][`PartialEq<Self>`]eq().(&self, other: &Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#) -> bool {
41 self.majorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#major. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().other.majorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#major. && self.minorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#minor. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().other.minorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#minor.
42 }
43 }
44
45 impl Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord# for Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version# {
46 fn cmprust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version][Ord]cmp().(&self, other: &Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#) -> cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering# {
47 match self.majorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#major..cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][Ord]cmp().(&other.majorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#major.) {
48 cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# => {}
49 r => return r,
50 }
51 match self.minorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#minor..cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][Ord]cmp().(&other.minorrust-analyzer cargo notify-rust 4.18.0 miniver/Version#minor.) {
52 cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# => {}
53 r => return r,
54 }
55 cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal#
56 }
57 }
58
59 #[cfg(test)]
60 mod testsrust-analyzer cargo notify-rust 4.18.0 miniver/tests/ {
61 use superrust-analyzer cargo notify-rust 4.18.0 miniver/::*;
62
63 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
64 fn version_parsingrust-analyzer cargo notify-rust 4.18.0 miniver/tests/version_parsing().() {
65 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("1.3".parserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]parse().::<Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 3));
66 }
67
68 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
69 fn version_comparisonrust-analyzer cargo notify-rust 4.18.0 miniver/tests/version_comparison().() {
70 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 3) >= Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 2));
71 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 2) >= Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 2));
72 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 2) == Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 2));
73 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 1) <= Versionrust-analyzer cargo notify-rust 4.18.0 miniver/Version#::newrust-analyzer cargo notify-rust 4.18.0 miniver/impl#[Version]new().(1, 2));
74 }
75 }