pub struct Version { /* private fields */ }Expand description
A version attached to an OS or to an environment.
Minor and patch are optional and absent is not zero. macos.13 and macos.13.0 are the
same deployment target, and a version type that normalized one to the other would not round
trip, so both spellings survive formatting and compare equal.
Implementations§
Source§impl Version
impl Version
Sourcepub const fn major(major: u32) -> Self
pub const fn major(major: u32) -> Self
A version with only a major component. linux-gnu.2 is not useful and wasip1 is
exactly this.
Sourcepub const fn new(major: u32, minor: u32) -> Self
pub const fn new(major: u32, minor: u32) -> Self
A two component version, which is what a glibc version is.
Sourcepub const fn full(major: u32, minor: u32, patch: u32) -> Self
pub const fn full(major: u32, minor: u32, patch: u32) -> Self
A three component version, which is what an SDK version is.
Sourcepub fn parse(s: &str) -> Option<Self>
pub fn parse(s: &str) -> Option<Self>
Read one, two or three dot separated numbers. Anything else is not a version.
Public because a version written down is not only ever a piece of a tuple. A sysroot’s
manifest records the Linux release its kernel headers came out of, and the thing it has to
read back is the same one, two or three numbers, so it reads them with this rather than with
a second parser that would disagree about 6.12. in a year.
Sourcepub const fn major_part(self) -> u32
pub const fn major_part(self) -> u32
The major component.
Sourcepub const fn minor_part(self) -> Option<u32>
pub const fn minor_part(self) -> Option<u32>
The minor component, if the tuple gave one.
Sourcepub const fn patch_part(self) -> Option<u32>
pub const fn patch_part(self) -> Option<u32>
The patch component, if the tuple gave one.
Sourcepub const fn to_triple(self) -> (u32, u32, u32)
pub const fn to_triple(self) -> (u32, u32, u32)
The version as a three component tuple with absent components read as zero, which is the
form to compare in. Do not use it to format: formatting from this loses the distinction
between 13 and 13.0.
Sourcepub const fn at_least(self, other: Version) -> bool
pub const fn at_least(self, other: Version) -> bool
Whether this version is at least other, comparing on the zero filled form.
Sourcepub fn to_llvm_string(self) -> String
pub fn to_llvm_string(self) -> String
The LLVM spelling, which always has three components. macosx13.0.0 rather than
macos.13.