Struct nodejs_semver::Version
source · 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 PartialEq for Version
impl PartialEq for Version
source§impl PartialOrd for Version
impl PartialOrd for Version
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreimpl Eq for Version
Auto Trait Implementations§
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