pub struct Version<T: Ord> {
pub major: T,
pub minor: T,
pub patch: T,
pub build: Option<T>,
}
Expand description
A struct that represents a version consisting of major, minor, patch, and an optional build number.
The generic parameter T
specifies the numerical type to use for each version component.
§Examples
Creating a version without a build number:
use simple_version::Version;
let version: Version<u32> = Version::new(1, 2, 3);
Creating a version with a build number:
use simple_version::Version;
let version: Version<u32> = Version::new(1, 2, 3).build(4);
Fields§
§major: T
The major version component.
§Examples
use simple_version::Version;
let mut version = Version::<u32>::new(1, 2, 3);
// read major version
println!("{}", version.major);
// set major version
version.major = 4;
minor: T
The minor version component.
§Examples
use simple_version::Version;
let mut version = Version::<u32>::new(1, 2, 3);
// read minor version
println!("{}", version.minor);
// set minor version
version.minor = 4;
patch: T
The patch version component.
§Examples
use simple_version::Version;
let mut version = Version::<u32>::new(1, 2, 3);
// read patch version
println!("{}", version.patch);
// set patch version
version.patch = 4;
build: Option<T>
The optional build number.
§Examples
use simple_version::Version;
// version with a build number
let mut version = Version::<u32>::new(1, 2, 3).build(4);
// read build number
if let Some(build) = version.build {
println!("{}", build);
}
// set build number
version.build = Some(5);
Implementations§
Trait Implementations§
Source§impl<T: Ord + Ord> Ord for Version<T>
impl<T: Ord + Ord> Ord for Version<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<T: PartialOrd + Ord> PartialOrd for Version<T>
impl<T: PartialOrd + Ord> PartialOrd for Version<T>
impl<T: Eq + Ord> Eq for Version<T>
impl<T: Ord> StructuralPartialEq for Version<T>
Auto Trait Implementations§
impl<T> Freeze for Version<T>where
T: Freeze,
impl<T> RefUnwindSafe for Version<T>where
T: RefUnwindSafe,
impl<T> Send for Version<T>where
T: Send,
impl<T> Sync for Version<T>where
T: Sync,
impl<T> Unpin for Version<T>where
T: Unpin,
impl<T> UnwindSafe for Version<T>where
T: UnwindSafe,
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