Enum rustpython_ast::located::Constant
source · pub enum Constant {
None,
Bool(bool),
Str(String),
Bytes(Vec<u8>),
Int(BigInt),
Tuple(Vec<Constant>),
Float(f64),
Complex {
real: f64,
imag: f64,
},
Ellipsis,
}
Variants§
None
Bool(bool)
Str(String)
Bytes(Vec<u8>)
Int(BigInt)
Tuple(Vec<Constant>)
Float(f64)
Complex
Ellipsis
Implementations§
source§impl Constant
impl Constant
sourcepub fn as_bool(&self) -> Option<&bool>
pub fn as_bool(&self) -> Option<&bool>
Returns Some
if self
is a reference of variant Bool
, and None
otherwise.
sourcepub fn as_mut_bool(&mut self) -> Option<&mut bool>
pub fn as_mut_bool(&mut self) -> Option<&mut bool>
Returns Some
if self
is a mutable reference of variant Bool
, and None
otherwise.
sourcepub fn expect_bool(self) -> boolwhere
Self: Debug,
pub fn expect_bool(self) -> boolwhere
Self: Debug,
sourcepub fn as_str(&self) -> Option<&String>
pub fn as_str(&self) -> Option<&String>
Returns Some
if self
is a reference of variant Str
, and None
otherwise.
sourcepub fn as_mut_str(&mut self) -> Option<&mut String>
pub fn as_mut_str(&mut self) -> Option<&mut String>
Returns Some
if self
is a mutable reference of variant Str
, and None
otherwise.
sourcepub fn expect_str(self) -> Stringwhere
Self: Debug,
pub fn expect_str(self) -> Stringwhere
Self: Debug,
sourcepub fn as_bytes(&self) -> Option<&Vec<u8>>
pub fn as_bytes(&self) -> Option<&Vec<u8>>
Returns Some
if self
is a reference of variant Bytes
, and None
otherwise.
sourcepub fn as_mut_bytes(&mut self) -> Option<&mut Vec<u8>>
pub fn as_mut_bytes(&mut self) -> Option<&mut Vec<u8>>
Returns Some
if self
is a mutable reference of variant Bytes
, and None
otherwise.
sourcepub fn bytes(self) -> Option<Vec<u8>>
pub fn bytes(self) -> Option<Vec<u8>>
Returns Some
if self
is of variant Bytes
, and None
otherwise.
sourcepub fn as_int(&self) -> Option<&BigInt>
pub fn as_int(&self) -> Option<&BigInt>
Returns Some
if self
is a reference of variant Int
, and None
otherwise.
sourcepub fn as_mut_int(&mut self) -> Option<&mut BigInt>
pub fn as_mut_int(&mut self) -> Option<&mut BigInt>
Returns Some
if self
is a mutable reference of variant Int
, and None
otherwise.
sourcepub fn expect_int(self) -> BigIntwhere
Self: Debug,
pub fn expect_int(self) -> BigIntwhere
Self: Debug,
sourcepub fn as_tuple(&self) -> Option<&Vec<Constant>>
pub fn as_tuple(&self) -> Option<&Vec<Constant>>
Returns Some
if self
is a reference of variant Tuple
, and None
otherwise.
sourcepub fn as_mut_tuple(&mut self) -> Option<&mut Vec<Constant>>
pub fn as_mut_tuple(&mut self) -> Option<&mut Vec<Constant>>
Returns Some
if self
is a mutable reference of variant Tuple
, and None
otherwise.
sourcepub fn expect_tuple(self) -> Vec<Constant>where
Self: Debug,
pub fn expect_tuple(self) -> Vec<Constant>where
Self: Debug,
sourcepub fn tuple(self) -> Option<Vec<Constant>>
pub fn tuple(self) -> Option<Vec<Constant>>
Returns Some
if self
is of variant Tuple
, and None
otherwise.
sourcepub fn as_float(&self) -> Option<&f64>
pub fn as_float(&self) -> Option<&f64>
Returns Some
if self
is a reference of variant Float
, and None
otherwise.
sourcepub fn as_mut_float(&mut self) -> Option<&mut f64>
pub fn as_mut_float(&mut self) -> Option<&mut f64>
Returns Some
if self
is a mutable reference of variant Float
, and None
otherwise.
sourcepub fn expect_float(self) -> f64where
Self: Debug,
pub fn expect_float(self) -> f64where
Self: Debug,
sourcepub fn float(self) -> Option<f64>
pub fn float(self) -> Option<f64>
Returns Some
if self
is of variant Float
, and None
otherwise.
sourcepub const fn is_complex(&self) -> bool
pub const fn is_complex(&self) -> bool
Returns true
if self
is of variant Complex
.
sourcepub const fn is_ellipsis(&self) -> bool
pub const fn is_ellipsis(&self) -> bool
Returns true
if self
is of variant Ellipsis
.