pub enum AnyStringPrefix {
Bytes(ByteStringPrefix),
Format(FStringPrefix),
Template(TStringPrefix),
Regular(StringLiteralPrefix),
}Expand description
Enumeration of all the possible valid prefixes prior to a Python string literal.
Using the as_flags() method on variants of this enum
is the recommended way to set *_PREFIX flags from the
StringFlags bitflag, as it means that you cannot accidentally
set a combination of *_PREFIX flags that would be invalid
at runtime in Python.
Variants§
Bytes(ByteStringPrefix)
Prefixes that indicate the string is a bytestring
Format(FStringPrefix)
Prefixes that indicate the string is an f-string
Template(TStringPrefix)
Prefixes that indicate the string is a t-string
Regular(StringLiteralPrefix)
All other prefixes
Implementations§
Source§impl AnyStringPrefix
impl AnyStringPrefix
Sourcepub fn as_bytes(&self) -> Option<&ByteStringPrefix>
pub fn as_bytes(&self) -> Option<&ByteStringPrefix>
Returns Some if self is a reference of variant Bytes, and None otherwise.
Sourcepub fn as_mut_bytes(&mut self) -> Option<&mut ByteStringPrefix>
pub fn as_mut_bytes(&mut self) -> Option<&mut ByteStringPrefix>
Returns Some if self is a mutable reference of variant Bytes, and None otherwise.
Sourcepub fn expect_bytes(self) -> ByteStringPrefixwhere
Self: Debug,
pub fn expect_bytes(self) -> ByteStringPrefixwhere
Self: Debug,
Sourcepub fn bytes(self) -> Option<ByteStringPrefix>
pub fn bytes(self) -> Option<ByteStringPrefix>
Returns Some if self is of variant Bytes, and None otherwise.
Sourcepub fn as_format(&self) -> Option<&FStringPrefix>
pub fn as_format(&self) -> Option<&FStringPrefix>
Returns Some if self is a reference of variant Format, and None otherwise.
Sourcepub fn as_mut_format(&mut self) -> Option<&mut FStringPrefix>
pub fn as_mut_format(&mut self) -> Option<&mut FStringPrefix>
Returns Some if self is a mutable reference of variant Format, and None otherwise.
Sourcepub fn expect_format(self) -> FStringPrefixwhere
Self: Debug,
pub fn expect_format(self) -> FStringPrefixwhere
Self: Debug,
Sourcepub fn format(self) -> Option<FStringPrefix>
pub fn format(self) -> Option<FStringPrefix>
Returns Some if self is of variant Format, and None otherwise.
Sourcepub const fn is_template(&self) -> bool
pub const fn is_template(&self) -> bool
Returns true if self is of variant Template.
Sourcepub fn as_template(&self) -> Option<&TStringPrefix>
pub fn as_template(&self) -> Option<&TStringPrefix>
Returns Some if self is a reference of variant Template, and None otherwise.
Sourcepub fn as_mut_template(&mut self) -> Option<&mut TStringPrefix>
pub fn as_mut_template(&mut self) -> Option<&mut TStringPrefix>
Returns Some if self is a mutable reference of variant Template, and None otherwise.
Sourcepub fn expect_template(self) -> TStringPrefixwhere
Self: Debug,
pub fn expect_template(self) -> TStringPrefixwhere
Self: Debug,
Sourcepub fn template(self) -> Option<TStringPrefix>
pub fn template(self) -> Option<TStringPrefix>
Returns Some if self is of variant Template, and None otherwise.
Sourcepub const fn is_regular(&self) -> bool
pub const fn is_regular(&self) -> bool
Returns true if self is of variant Regular.
Sourcepub fn as_regular(&self) -> Option<&StringLiteralPrefix>
pub fn as_regular(&self) -> Option<&StringLiteralPrefix>
Returns Some if self is a reference of variant Regular, and None otherwise.
Sourcepub fn as_mut_regular(&mut self) -> Option<&mut StringLiteralPrefix>
pub fn as_mut_regular(&mut self) -> Option<&mut StringLiteralPrefix>
Returns Some if self is a mutable reference of variant Regular, and None otherwise.
Sourcepub fn expect_regular(self) -> StringLiteralPrefixwhere
Self: Debug,
pub fn expect_regular(self) -> StringLiteralPrefixwhere
Self: Debug,
Sourcepub fn regular(self) -> Option<StringLiteralPrefix>
pub fn regular(self) -> Option<StringLiteralPrefix>
Returns Some if self is of variant Regular, and None otherwise.
Trait Implementations§
Source§impl Clone for AnyStringPrefix
impl Clone for AnyStringPrefix
Source§fn clone(&self) -> AnyStringPrefix
fn clone(&self) -> AnyStringPrefix
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnyStringPrefix
impl Debug for AnyStringPrefix
Source§impl Default for AnyStringPrefix
impl Default for AnyStringPrefix
Source§impl Display for AnyStringPrefix
impl Display for AnyStringPrefix
Source§impl Hash for AnyStringPrefix
impl Hash for AnyStringPrefix
Source§impl PartialEq for AnyStringPrefix
impl PartialEq for AnyStringPrefix
impl Copy for AnyStringPrefix
impl Eq for AnyStringPrefix
impl StructuralPartialEq for AnyStringPrefix
Auto Trait Implementations§
impl Freeze for AnyStringPrefix
impl RefUnwindSafe for AnyStringPrefix
impl Send for AnyStringPrefix
impl Sync for AnyStringPrefix
impl Unpin for AnyStringPrefix
impl UnsafeUnpin for AnyStringPrefix
impl UnwindSafe for AnyStringPrefix
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