pub struct CompareVersion;Implementations§
Source§impl CompareVersion
impl CompareVersion
Sourcepub fn compare_version(
version1: &str,
version2: &str,
) -> Result<VersionComparison, VersionError>
pub fn compare_version( version1: &str, version2: &str, ) -> Result<VersionComparison, VersionError>
Compares two version strings and returns a VersionComparison enum.
§Arguments
version1- A string slice that holds the first version to compare.version2- A string slice that holds the second version to compare.
§Errors
Returns a VersionError if either version cannot be parsed.
§Examples
use compare_version::*;
let result = CompareVersion::compare_version("1.2.3", "1.2.4");
assert_eq!(result, Ok(VersionComparison::Less));Sourcepub fn matches_version_range(
version: &str,
range: &str,
) -> Result<bool, VersionError>
pub fn matches_version_range( version: &str, range: &str, ) -> Result<bool, VersionError>
Checks whether a version matches a specified range, supporting ^ and ~ ranges.
§Arguments
version- A string slice that holds the version to check against the range.range- A string slice that holds the version range to check.
§Errors
Returns a VersionError if the version or range cannot be parsed.
§Examples
use compare_version::*;
let matches = CompareVersion::matches_version_range("1.2.3", "^1.2.0");
assert_eq!(matches, Ok(true));use compare_version::*;
let matches = CompareVersion::matches_version_range("1.2.3", "~1.2.4");
assert_eq!(matches, Ok(false));Auto Trait Implementations§
impl Freeze for CompareVersion
impl RefUnwindSafe for CompareVersion
impl Send for CompareVersion
impl Sync for CompareVersion
impl Unpin for CompareVersion
impl UnwindSafe for CompareVersion
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