pub struct Version { /* private fields */ }
Expand description
Implementations§
Source§impl Version
impl Version
Sourcepub const fn default_const() -> Self
pub const fn default_const() -> Self
Create a empty version.
§Examples
use commonlibsse_ng::rel::version::Version;
assert_eq!(Version::default_const(), Version::new(0, 0, 0, 0));
Sourcepub const fn new(major: u16, minor: u16, patch: u16, build: u16) -> Self
pub const fn new(major: u16, minor: u16, patch: u16, build: u16) -> Self
Creates a new Version
from four components.
§Example
use commonlibsse_ng::rel::version::Version;
let ver = Version::new(1, 2, 3, 4);
assert_eq!(ver.major(), 1);
Sourcepub const fn from_str_const(version: &str) -> Self
pub const fn from_str_const(version: &str) -> Self
Parses a version string at compile time.
§Panics
Errors are made under the following conditions.
- When there is no number after a point.
- If there are more than 4 numbers.
- When there is a non-numeric character (other than a dot).
§Examples
use commonlibsse_ng::rel::version::{Version, VersionParseError};
assert_eq!(Version::from_str_const("1.2.3"), Version::new(1, 2, 3, 0));
// Panics
// assert_eq!(Version::from_str_const_("1.2.3.4.5")); // Too many numbers
// assert_eq!(Version::from_str_const("1.2.f.4.5")); // Invalid char `f`
// assert_eq!(Version::from_str_const("1.2.")); // Missing number
Sourcepub const fn major(&self) -> u16
pub const fn major(&self) -> u16
Returns the major version component.
§Examples
use commonlibsse_ng::rel::version::Version;
let v = Version::new(1, 2, 3, 4);
assert_eq!(v.major(), 1);
Sourcepub const fn minor(&self) -> u16
pub const fn minor(&self) -> u16
Returns the minor version component.
§Examples
use commonlibsse_ng::rel::version::Version;
let v = Version::new(1, 2, 3, 4);
assert_eq!(v.minor(), 2);
Sourcepub const fn patch(&self) -> u16
pub const fn patch(&self) -> u16
Returns the patch version component.
§Examples
use commonlibsse_ng::rel::version::Version;
let v = Version::new(1, 2, 3, 4);
assert_eq!(v.patch(), 3);
Sourcepub const fn build(&self) -> u16
pub const fn build(&self) -> u16
Returns the build version component.
§Examples
use commonlibsse_ng::rel::version::Version;
let v = Version::new(1, 2, 3, 4);
assert_eq!(v.build(), 4);
Sourcepub const fn pack(&self) -> u32
pub const fn pack(&self) -> u32
Packs the version into a 32-bit integer.
§Examples
use commonlibsse_ng::rel::version::Version;
let v = Version::new(1, 2, 3, 4);
assert_eq!(v.pack(), 16908340);
Sourcepub const fn parts(&self) -> [u16; 4]
pub const fn parts(&self) -> [u16; 4]
Gets the inner parts.
§Example
let v = Version::new(1, 2, 3, 4);
assert_eq!(v.parts(), [1, 2, 3, 4]);
Sourcepub fn to_address_library_string(&self) -> String
pub fn to_address_library_string(&self) -> String
To address library file name string.
§Example
let v = Version::new(1, 2, 3, 4);
assert_eq!(v.to_address_library_string(), "1-2-3-4");
Trait Implementations§
Source§impl Ord for Version
impl Ord for Version
Source§impl PartialOrd for Version
impl PartialOrd for Version
impl Eq for Version
impl StructuralPartialEq 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