pub enum Value<'a> {
Literal(Cow<'a, str>),
Number(i64),
Concat(Box<[Self]>),
Variable(Cow<'a, str>),
}Expand description
A value in a BibTeX field
§Memory Optimization
Concatenation parts are stored out of line so the common literal, number, and variable variants stay compact.
Variants§
Literal(Cow<'a, str>)
String literal
Number(i64)
Number literal
Concat(Box<[Self]>)
Concatenated values (boxed to reduce enum size)
Variable(Cow<'a, str>)
Variable reference
Implementations§
Source§impl Value<'_>
impl Value<'_>
Sourcepub fn expand(&self, strings: &AHashMap<&str, Value<'_>>) -> String
pub fn expand(&self, strings: &AHashMap<&str, Value<'_>>) -> String
Expand variables and concatenations to get final string
Sourcepub fn to_plain_string(&self) -> String
pub fn to_plain_string(&self) -> String
Project this value to ordinary text without adding unresolved-variable markers.
Literals and numbers become their text form, variables become their variable name, and concatenations are joined recursively. This allocates when the value is not already a simple borrowed literal.
Sourcepub fn to_lossy_string(&self) -> String
pub fn to_lossy_string(&self) -> String
Project this value to display text, marking unresolved variables as {name}.
Sourcepub fn from_plain_string<'a>(text: impl Into<Cow<'a, str>>) -> Value<'a>
pub fn from_plain_string<'a>(text: impl Into<Cow<'a, str>>) -> Value<'a>
Create a literal value from ordinary text.
Sourcepub fn to_bibtex_source(&self) -> String
pub fn to_bibtex_source(&self) -> String
Serialize this value as a BibTeX value fragment.
This is a normalized source projection. Use source-preserving parsing when callers need the exact original spelling or delimiters.
Sourcepub fn to_unicode_plain_string(&self) -> String
pub fn to_unicode_plain_string(&self) -> String
Project this value to ordinary text and convert common LaTeX sequences to Unicode.
Sourcepub fn into_owned(self) -> Value<'static>
pub fn into_owned(self) -> Value<'static>
Convert to owned version
Trait Implementations§
impl<'a> StructuralPartialEq for Value<'a>
Auto Trait Implementations§
impl<'a> Freeze for Value<'a>
impl<'a> RefUnwindSafe for Value<'a>
impl<'a> Send for Value<'a>
impl<'a> Sync for Value<'a>
impl<'a> Unpin for Value<'a>
impl<'a> UnsafeUnpin for Value<'a>
impl<'a> UnwindSafe for Value<'a>
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