pub struct StringLiteralValue { /* private fields */ }Expand description
The value representing a ExprStringLiteral.
Implementations§
Source§impl StringLiteralValue
impl StringLiteralValue
Sourcepub fn single(string: StringLiteral) -> StringLiteralValue
pub fn single(string: StringLiteral) -> StringLiteralValue
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>) -> StringLiteralValue
pub fn concatenated(strings: Vec<StringLiteral>) -> StringLiteralValue
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 GetSize for StringLiteralValue
impl GetSize for StringLiteralValue
Source§fn get_heap_size(&self) -> usize
fn get_heap_size(&self) -> usize
Source§fn get_heap_size_with_tracker<TRACKER>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)where
TRACKER: GetSizeTracker,
fn get_heap_size_with_tracker<TRACKER>(
&self,
tracker: TRACKER,
) -> (usize, TRACKER)where
TRACKER: GetSizeTracker,
tracker. Read moreSource§fn get_stack_size() -> usize
fn get_stack_size() -> usize
Source§fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
fn get_size_with_tracker<T>(&self, tracker: T) -> (usize, T)where
T: GetSizeTracker,
tracker. Read moreSource§impl<'a> IntoIterator for &'a StringLiteralValue
impl<'a> IntoIterator for &'a StringLiteralValue
Source§type Item = &'a StringLiteral
type Item = &'a StringLiteral
Source§type IntoIter = Iter<'a, StringLiteral>
type IntoIter = Iter<'a, StringLiteral>
Source§fn into_iter(self) -> <&'a StringLiteralValue as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a StringLiteralValue as IntoIterator>::IntoIter
Source§impl<'a> IntoIterator for &'a mut StringLiteralValue
impl<'a> IntoIterator for &'a mut StringLiteralValue
Source§type Item = &'a mut StringLiteral
type Item = &'a mut StringLiteral
Source§type IntoIter = IterMut<'a, StringLiteral>
type IntoIter = IterMut<'a, StringLiteral>
Source§fn into_iter(self) -> <&'a mut StringLiteralValue as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a mut StringLiteralValue as IntoIterator>::IntoIter
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, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
Source§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
Source§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