pub struct StringLiteralValue { /* private fields */ }Expand description
The value representing a ExprStringLiteral.
Implementations§
Source§impl StringLiteralValue
impl StringLiteralValue
Sourcepub fn single(string: StringLiteral) -> Self
pub fn single(string: StringLiteral) -> Self
Creates a new string literal with a single StringLiteral part.
Sourcepub fn first_literal_flags(&self) -> StringLiteralFlags
pub fn first_literal_flags(&self) -> StringLiteralFlags
Returns the StringLiteralFlags associated with this string literal.
For an implicitly concatenated string, it returns the flags for the first literal.
Sourcepub fn concatenated(strings: Vec<StringLiteral>) -> Self
pub fn concatenated(strings: Vec<StringLiteral>) -> Self
Creates a new string literal with the given values that represents an implicitly concatenated strings.
§Panics
Panics if strings has less than 2 elements.
Use StringLiteralValue::single instead.
Sourcepub const fn is_implicit_concatenated(&self) -> bool
pub const fn is_implicit_concatenated(&self) -> bool
Returns true if the string literal is implicitly concatenated.
Sourcepub fn is_unicode(&self) -> bool
pub fn is_unicode(&self) -> bool
Returns true if the string literal has a u prefix, e.g. u"foo".
Although all strings in Python 3 are valid unicode (and the u prefix
is only retained for backwards compatibility), these strings are known as
“unicode strings”.
For an implicitly concatenated string, it returns true only if the first
StringLiteral has the u prefix.
Sourcepub fn as_slice(&self) -> &[StringLiteral]
pub fn as_slice(&self) -> &[StringLiteral]
Returns a slice of all the StringLiteral parts contained in this value.
Sourcepub fn iter(&self) -> Iter<'_, StringLiteral>
pub fn iter(&self) -> Iter<'_, StringLiteral>
Returns an iterator over all the StringLiteral parts contained in this value.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, StringLiteral>
pub fn iter_mut(&mut self) -> IterMut<'_, StringLiteral>
Returns an iterator over all the StringLiteral parts contained in this value
that allows modification.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the node represents an empty string.
Note that a StringLiteralValue node will always have >=1 StringLiteral parts
inside it. This method checks whether the value of the concatenated parts is equal
to the empty string, not whether the string has 0 parts inside it.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the total length of the string literal value, in bytes, not
chars or graphemes.
Trait Implementations§
Source§impl Clone for StringLiteralValue
impl Clone for StringLiteralValue
Source§fn clone(&self) -> StringLiteralValue
fn clone(&self) -> StringLiteralValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StringLiteralValue
impl Debug for StringLiteralValue
Source§impl Display for StringLiteralValue
impl Display for StringLiteralValue
Source§impl<'a> IntoIterator for &'a StringLiteralValue
impl<'a> IntoIterator for &'a StringLiteralValue
Source§impl<'a> IntoIterator for &'a mut StringLiteralValue
impl<'a> IntoIterator for &'a mut StringLiteralValue
Source§impl PartialEq<str> for StringLiteralValue
impl PartialEq<str> for StringLiteralValue
Source§impl PartialEq for StringLiteralValue
impl PartialEq for StringLiteralValue
impl StructuralPartialEq for StringLiteralValue
Auto Trait Implementations§
impl !Freeze for StringLiteralValue
impl RefUnwindSafe for StringLiteralValue
impl Send for StringLiteralValue
impl Sync for StringLiteralValue
impl Unpin for StringLiteralValue
impl UnsafeUnpin for StringLiteralValue
impl UnwindSafe for StringLiteralValue
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 moreSource§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more