pub struct Pkgver(pub(crate) String);
Expand description
A pkgver of a package
Pkgver is used to denote the upstream version of a package.
A Pkgver wraps a String
, which is guaranteed to only contain alphanumeric characters, "_"
,
"+"
or "."
, but to not start with a "_"
, a "+"
or a "."
character and to be at least
one char long.
NOTE: This implementation of Pkgver is stricter than that of libalpm/pacman. It does not allow
empty strings ""
, or chars that are not in the allowed set, or "."
as the first character.
§Examples
use std::str::FromStr;
use alpm_types::Pkgver;
assert!(Pkgver::new("1".to_string()).is_ok());
assert!(Pkgver::new("1.1".to_string()).is_ok());
assert!(Pkgver::new("foo".to_string()).is_ok());
assert!(Pkgver::new("0".to_string()).is_ok());
assert!(Pkgver::new(".0.1".to_string()).is_err());
assert!(Pkgver::new("_1.0".to_string()).is_err());
assert!(Pkgver::new("+1.0".to_string()).is_err());
Tuple Fields§
§0: String
Implementations§
Trait Implementations§
source§impl Ord for Pkgver
impl Ord for Pkgver
source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
This block implements the logic to determine which of two package versions is newer or whether they’re considered equal.
This logic is surprisingly complex as it mirrors the current C-alpmlib implementation for backwards compatibility reasons. https://gitlab.archlinux.org/pacman/pacman/-/blob/a2d029388c7c206f5576456f91bfbea2dca98c96/lib/libalpm/version.c#L83-217
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialOrd for Pkgver
impl PartialOrd for Pkgver
impl Eq for Pkgver
Auto Trait Implementations§
impl Freeze for Pkgver
impl RefUnwindSafe for Pkgver
impl Send for Pkgver
impl Sync for Pkgver
impl Unpin for Pkgver
impl UnwindSafe for Pkgver
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)