pub struct TStringValue { /* private fields */ }Expand description
The value representing an ExprTString.
Implementations§
Source§impl TStringValue
impl TStringValue
Sourcepub fn single(value: TString) -> Self
pub fn single(value: TString) -> Self
Creates a new t-string literal with a single TString part.
Sourcepub fn concatenated(values: Vec<TString>) -> Self
pub fn concatenated(values: Vec<TString>) -> Self
Creates a new t-string with the given values that represents an implicitly concatenated t-string.
§Panics
Panics if values has less than 2 elements.
Use TStringValue::single instead.
Sourcepub fn is_implicit_concatenated(&self) -> bool
pub fn is_implicit_concatenated(&self) -> bool
Returns true if the t-string is implicitly concatenated, false otherwise.
Sourcepub fn as_slice(&self) -> &[TString]
pub fn as_slice(&self) -> &[TString]
Returns a slice of all the TStrings contained in this value.
Sourcepub fn iter(&self) -> Iter<'_, TString>
pub fn iter(&self) -> Iter<'_, TString>
Returns an iterator over all the TStrings contained in this value.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, TString>
pub fn iter_mut(&mut self) -> IterMut<'_, TString>
Returns an iterator over all the TStrings contained in this value
that allows modification.
Sourcepub fn elements(&self) -> impl Iterator<Item = &InterpolatedStringElement>
pub fn elements(&self) -> impl Iterator<Item = &InterpolatedStringElement>
Returns an iterator over all the InterpolatedStringElement contained in this value.
An interpolated string element is what makes up an TString i.e., it is either a
string literal or an interpolation. In the following example,
t"foo" t"bar {x}" t"baz" t"qux"The interpolated string elements returned would be string literal ("bar "),
interpolation (x) and string literal ("qux").
Sourcepub fn is_empty_iterable(&self) -> bool
pub fn is_empty_iterable(&self) -> bool
Returns true if the node represents an empty t-string in the
sense that __iter__ returns an empty iterable.
Beware that empty t-strings are still truthy, i.e. bool(t"") == True.
Note that a TStringValue node will always contain at least one
TString node. This method checks whether each of the constituent
t-strings (in an implicitly concatenated t-string) are empty
in the above sense.
Trait Implementations§
Source§impl Clone for TStringValue
impl Clone for TStringValue
Source§fn clone(&self) -> TStringValue
fn clone(&self) -> TStringValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TStringValue
impl Debug for TStringValue
Source§impl<'a> From<&'a TStringValue> for ComparableTString<'a>
impl<'a> From<&'a TStringValue> for ComparableTString<'a>
Source§fn from(value: &'a TStringValue) -> Self
fn from(value: &'a TStringValue) -> Self
Source§impl<'a> IntoIterator for &'a TStringValue
impl<'a> IntoIterator for &'a TStringValue
Source§impl<'a> IntoIterator for &'a mut TStringValue
impl<'a> IntoIterator for &'a mut TStringValue
Source§impl PartialEq for TStringValue
impl PartialEq for TStringValue
impl StructuralPartialEq for TStringValue
Auto Trait Implementations§
impl !Freeze for TStringValue
impl RefUnwindSafe for TStringValue
impl Send for TStringValue
impl Sync for TStringValue
impl Unpin for TStringValue
impl UnsafeUnpin for TStringValue
impl UnwindSafe for TStringValue
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