pub enum CifValue {
Inapplicable,
Unknown,
Text(Arc<str>),
Integer(i64),
Float(f64),
}Expand description
One value of one item.
Variants§
Inapplicable
Written . — the item does not apply here.
Unknown
Written ? — the value exists but was not recorded.
Text(Arc<str>)
Text.
Integer(i64)
A whole number.
Kept as an integer rather than as a float: a serial number past two to the fifty-third would otherwise stop round-tripping exactly, and the files that reach those numbers are precisely the large ones.
Float(f64)
A number with a fractional part.
Implementations§
Source§impl CifValue
impl CifValue
Sourcepub fn parse(text: &str, quoting: Quoting) -> Self
pub fn parse(text: &str, quoting: Quoting) -> Self
Interprets a lexed value, deciding what kind of thing it is.
Only a bare value can be a number or a sentinel. '.' written in quotes
is the one-character string, not the sentinel, and the format is explicit
about the difference.
Sourcepub fn as_identifier(&self) -> Option<Cow<'_, str>>
pub fn as_identifier(&self) -> Option<Cow<'_, str>>
The value as an identifier, whatever kind of thing it was written as.
Identifiers in this format are frequently numeric — entity numbers and chain labels especially — and reading them only as text drops them silently. Nothing is allocated unless the value really was a number.
Sourcepub fn as_integer(&self) -> Option<i64>
pub fn as_integer(&self) -> Option<i64>
The value as a whole number, where it is one.
Sourcepub fn as_float(&self) -> Option<f64>
pub fn as_float(&self) -> Option<f64>
The value as a number, whether it was written with a fractional part.
Sourcepub const fn is_recorded(&self) -> bool
pub const fn is_recorded(&self) -> bool
Returns true for a value that was recorded.
Trait Implementations§
impl StructuralPartialEq for CifValue
Auto Trait Implementations§
impl Freeze for CifValue
impl RefUnwindSafe for CifValue
impl Send for CifValue
impl Sync for CifValue
impl Unpin for CifValue
impl UnsafeUnpin for CifValue
impl UnwindSafe for CifValue
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more