pub enum Integer {
Signed(i64),
Unsigned(u64),
}Expand description
A property-list integer, carrying its signedness.
Plists must represent both u64::MAX and negative values, so the model is
the pair of a raw 64-bit payload and a sign flag rather than a single
i64. Equality, ordering, and hashing are numeric: no codec preserves
signedness for non-negative values, so Signed(5) and Unsigned(5) are
the same integer (and hash identically).
§Examples
use apple_plist::Integer;
assert_eq!(Integer::from(5i64), Integer::from(5u64));
assert!(Integer::from(-1i8) < Integer::from(0u8));Variants§
Signed(i64)
A signed value; the only representation negative integers have.
Unsigned(u64)
An unsigned value, covering i64::MAX + 1 ..= u64::MAX exclusively.
Implementations§
Source§impl Integer
impl Integer
Sourcepub const fn as_signed(self) -> Option<i64>
pub const fn as_signed(self) -> Option<i64>
Returns the value as an i64 when it fits.
§Examples
use apple_plist::Integer;
assert_eq!(
Integer::Unsigned(i64::MAX as u64).as_signed(),
Some(i64::MAX)
);
assert_eq!(Integer::Unsigned(i64::MAX as u64 + 1).as_signed(), None);
assert_eq!(Integer::Signed(-1).as_signed(), Some(-1));Sourcepub const fn as_unsigned(self) -> Option<u64>
pub const fn as_unsigned(self) -> Option<u64>
Returns the value as a u64 when it is non-negative.
§Examples
use apple_plist::Integer;
assert_eq!(Integer::Signed(0).as_unsigned(), Some(0));
assert_eq!(Integer::Signed(-1).as_unsigned(), None);
assert_eq!(Integer::Unsigned(u64::MAX).as_unsigned(), Some(u64::MAX));Trait Implementations§
impl Copy for Integer
Source§impl<'de> Deserialize<'de> for Integer
impl<'de> Deserialize<'de> for Integer
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Integer
Source§impl Ord for Integer
impl Ord for Integer
1.21.0 (const: unstable) · 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
Auto Trait Implementations§
impl Freeze for Integer
impl RefUnwindSafe for Integer
impl Send for Integer
impl Sync for Integer
impl Unpin for Integer
impl UnsafeUnpin for Integer
impl UnwindSafe for Integer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.