pub struct FStringValue { /* private fields */ }Expand description
The value representing an ExprFString.
Implementations§
Source§impl FStringValue
impl FStringValue
Sourcepub fn single(value: FString) -> Self
pub fn single(value: FString) -> Self
Creates a new f-string literal with a single FString part.
Sourcepub fn concatenated(values: Vec<FStringPart>) -> Self
pub fn concatenated(values: Vec<FStringPart>) -> Self
Creates a new f-string with the given values that represents an implicitly concatenated f-string.
§Panics
Panics if values has less than 2 elements.
Use FStringValue::single instead.
Sourcepub fn is_implicit_concatenated(&self) -> bool
pub fn is_implicit_concatenated(&self) -> bool
Returns true if the f-string is implicitly concatenated, false otherwise.
Sourcepub fn as_slice(&self) -> &[FStringPart]
pub fn as_slice(&self) -> &[FStringPart]
Returns a slice of all the FStringParts contained in this value.
Sourcepub fn iter(&self) -> Iter<'_, FStringPart>
pub fn iter(&self) -> Iter<'_, FStringPart>
Returns an iterator over all the FStringParts contained in this value.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, FStringPart>
pub fn iter_mut(&mut self) -> IterMut<'_, FStringPart>
Returns an iterator over all the FStringParts contained in this value
that allows modification.
Sourcepub fn literals(&self) -> impl Iterator<Item = &StringLiteral>
pub fn literals(&self) -> impl Iterator<Item = &StringLiteral>
Returns an iterator over the StringLiteral parts contained in this value.
Note that this doesn’t recurse into the f-string parts. For example,
"foo" f"bar {x}" "baz" f"qux"Here, the string literal parts returned would be "foo" and "baz".
Sourcepub fn f_strings(&self) -> impl Iterator<Item = &FString>
pub fn f_strings(&self) -> impl Iterator<Item = &FString>
Returns an iterator over the FString parts contained in this value.
Note that this doesn’t recurse into the f-string parts. For example,
"foo" f"bar {x}" "baz" f"qux"Here, the f-string parts returned would be f"bar {x}" and f"qux".
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 f-string element is what makes up an FString i.e., it is either a
string literal or an expression. In the following example,
"foo" f"bar {x}" "baz" f"qux"The f-string elements returned would be string literal ("bar "),
expression (x) and string literal ("qux").
Sourcepub fn is_empty_literal(&self) -> bool
pub fn is_empty_literal(&self) -> bool
Returns true if the node represents an empty f-string literal.
Note that a FStringValue node will always have >= 1 FStringParts inside it.
This method checks whether the value of the concatenated parts is equal to the empty
f-string, not whether the f-string has 0 parts inside it.
Trait Implementations§
Source§impl Clone for FStringValue
impl Clone for FStringValue
Source§fn clone(&self) -> FStringValue
fn clone(&self) -> FStringValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FStringValue
impl Debug for FStringValue
Source§impl<'a> From<&'a FStringValue> for ComparableFString<'a>
impl<'a> From<&'a FStringValue> for ComparableFString<'a>
Source§fn from(value: &'a FStringValue) -> Self
fn from(value: &'a FStringValue) -> Self
Source§impl<'a> IntoIterator for &'a FStringValue
impl<'a> IntoIterator for &'a FStringValue
Source§impl<'a> IntoIterator for &'a mut FStringValue
impl<'a> IntoIterator for &'a mut FStringValue
Source§impl PartialEq for FStringValue
impl PartialEq for FStringValue
impl StructuralPartialEq for FStringValue
Auto Trait Implementations§
impl !Freeze for FStringValue
impl RefUnwindSafe for FStringValue
impl Send for FStringValue
impl Sync for FStringValue
impl Unpin for FStringValue
impl UnsafeUnpin for FStringValue
impl UnwindSafe for FStringValue
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