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
.
Trait Implementations§
impl StructuralPartialEq for Constant
Auto Trait Implementations§
impl Freeze for Constant
impl RefUnwindSafe for Constant
impl Send for Constant
impl Sync for Constant
impl Unpin for Constant
impl UnwindSafe for Constant
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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 more