Enum rustpython_parser::StringKind
source · pub enum StringKind {
String,
FString,
Bytes,
RawString,
RawFString,
RawBytes,
Unicode,
}
Expand description
The kind of string literal as described in the String and Bytes literals section of the Python reference.
Variants§
String
A normal string literal with no prefix.
FString
A f-string literal, with a f
or F
prefix.
Bytes
A byte string literal, with a b
or B
prefix.
RawString
A raw string literal, with a r
or R
prefix.
RawFString
A raw f-string literal, with a rf
/fr
or rF
/Fr
or Rf
/fR
or RF
/FR
prefix.
RawBytes
A raw byte string literal, with a rb
/br
or rB
/Br
or Rb
/bR
or RB
/BR
prefix.
Unicode
A unicode string literal, with a u
or U
prefix.
Implementations§
source§impl StringKind
impl StringKind
sourcepub fn is_raw(&self) -> bool
pub fn is_raw(&self) -> bool
Returns true if the string is a raw string, i,e one of
StringKind::RawString
or StringKind::RawFString
or StringKind::RawBytes
.
sourcepub fn is_any_fstring(&self) -> bool
pub fn is_any_fstring(&self) -> bool
Returns true if the string is an f-string, i,e one of
StringKind::FString
or StringKind::RawFString
.
sourcepub fn is_any_bytes(&self) -> bool
pub fn is_any_bytes(&self) -> bool
Returns true if the string is a byte string, i,e one of
StringKind::Bytes
or StringKind::RawBytes
.
sourcepub fn is_unicode(&self) -> bool
pub fn is_unicode(&self) -> bool
Returns true if the string is a unicode string, i,e StringKind::Unicode
.
sourcepub fn prefix_len(&self) -> TextSize
pub fn prefix_len(&self) -> TextSize
Returns the number of characters in the prefix.
Trait Implementations§
source§impl Clone for StringKind
impl Clone for StringKind
source§fn clone(&self) -> StringKind
fn clone(&self) -> StringKind
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for StringKind
impl Debug for StringKind
source§impl Display for StringKind
impl Display for StringKind
source§impl Hash for StringKind
impl Hash for StringKind
source§impl PartialEq<StringKind> for StringKind
impl PartialEq<StringKind> for StringKind
source§fn eq(&self, other: &StringKind) -> bool
fn eq(&self, other: &StringKind) -> bool
self
and other
values to be equal, and is used
by ==
.