pub struct Version {
pub major: u64,
pub minor: u64,
pub patch: u64,
pub build: Vec<Identifier>,
pub pre_release: Vec<Identifier>,
}
Expand description
A semantic version, conformant to the semver spec.
Fields§
§major: u64
§minor: u64
§patch: u64
§build: Vec<Identifier>
§pre_release: Vec<Identifier>
Implementations§
Source§impl Version
impl Version
Sourcepub fn is_prerelease(&self) -> bool
pub fn is_prerelease(&self) -> bool
True is this Version has a prerelease component.
Sourcepub fn parse<S: AsRef<str>>(input: S) -> Result<Version, SemverError>
pub fn parse<S: AsRef<str>>(input: S) -> Result<Version, SemverError>
Parse a semver string into a Version.
use nodejs_semver::Version;
fn main() {
let v = Version::parse("1.2.3-rc.4").unwrap();
println!("{}", v);
}
Sourcepub fn diff(&self, other: &Self) -> Option<VersionDiff>
pub fn diff(&self, other: &Self) -> Option<VersionDiff>
difference between two Versions by the release type,
or None
if the Versions are the same.
use nodejs_semver::{Version, VersionDiff};
fn main() {
let v1 = Version::parse("1.2.3-rc.4").unwrap();
let v2 = Version::parse("1.2.3").unwrap();
let diff = v1.diff(&v2);
assert_eq!(diff, Some(VersionDiff::Patch));
}
Trait Implementations§
Source§impl Ord for Version
impl Ord for Version
Source§impl PartialOrd for Version
impl PartialOrd for Version
impl Eq for Version
Auto Trait Implementations§
impl Freeze for Version
impl RefUnwindSafe for Version
impl Send for Version
impl Sync for Version
impl Unpin for Version
impl UnwindSafe for Version
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more