Enum rustpython_ast::Mod
source · pub enum Mod<R = TextRange> {
Module(ModModule<R>),
Interactive(ModInteractive<R>),
Expression(ModExpression<R>),
FunctionType(ModFunctionType<R>),
}
Expand description
See also mod
Variants§
Module(ModModule<R>)
Interactive(ModInteractive<R>)
Expression(ModExpression<R>)
FunctionType(ModFunctionType<R>)
Implementations§
source§impl<R> Mod<R>
impl<R> Mod<R>
sourcepub fn as_module(&self) -> Option<&ModModule<R>>
pub fn as_module(&self) -> Option<&ModModule<R>>
Returns Some
if self
is a reference of variant Module
, and None
otherwise.
sourcepub fn as_mut_module(&mut self) -> Option<&mut ModModule<R>>
pub fn as_mut_module(&mut self) -> Option<&mut ModModule<R>>
Returns Some
if self
is a mutable reference of variant Module
, and None
otherwise.
sourcepub fn expect_module(self) -> ModModule<R>where
Self: Debug,
pub fn expect_module(self) -> ModModule<R>where
Self: Debug,
sourcepub fn module(self) -> Option<ModModule<R>>
pub fn module(self) -> Option<ModModule<R>>
Returns Some
if self
is of variant Module
, and None
otherwise.
sourcepub const fn is_interactive(&self) -> bool
pub const fn is_interactive(&self) -> bool
Returns true
if self
is of variant Interactive
.
sourcepub fn as_interactive(&self) -> Option<&ModInteractive<R>>
pub fn as_interactive(&self) -> Option<&ModInteractive<R>>
Returns Some
if self
is a reference of variant Interactive
, and None
otherwise.
sourcepub fn as_mut_interactive(&mut self) -> Option<&mut ModInteractive<R>>
pub fn as_mut_interactive(&mut self) -> Option<&mut ModInteractive<R>>
Returns Some
if self
is a mutable reference of variant Interactive
, and None
otherwise.
sourcepub fn expect_interactive(self) -> ModInteractive<R>where
Self: Debug,
pub fn expect_interactive(self) -> ModInteractive<R>where
Self: Debug,
Unwraps the value, yielding the content of Interactive
.
§Panics
Panics if the value is not Interactive
, with a panic message including the content of self
.
sourcepub fn interactive(self) -> Option<ModInteractive<R>>
pub fn interactive(self) -> Option<ModInteractive<R>>
Returns Some
if self
is of variant Interactive
, and None
otherwise.
sourcepub const fn is_expression(&self) -> bool
pub const fn is_expression(&self) -> bool
Returns true
if self
is of variant Expression
.
sourcepub fn as_expression(&self) -> Option<&ModExpression<R>>
pub fn as_expression(&self) -> Option<&ModExpression<R>>
Returns Some
if self
is a reference of variant Expression
, and None
otherwise.
sourcepub fn as_mut_expression(&mut self) -> Option<&mut ModExpression<R>>
pub fn as_mut_expression(&mut self) -> Option<&mut ModExpression<R>>
Returns Some
if self
is a mutable reference of variant Expression
, and None
otherwise.
sourcepub fn expect_expression(self) -> ModExpression<R>where
Self: Debug,
pub fn expect_expression(self) -> ModExpression<R>where
Self: Debug,
Unwraps the value, yielding the content of Expression
.
§Panics
Panics if the value is not Expression
, with a panic message including the content of self
.
sourcepub fn expression(self) -> Option<ModExpression<R>>
pub fn expression(self) -> Option<ModExpression<R>>
Returns Some
if self
is of variant Expression
, and None
otherwise.
sourcepub const fn is_function_type(&self) -> bool
pub const fn is_function_type(&self) -> bool
Returns true
if self
is of variant FunctionType
.
sourcepub fn as_function_type(&self) -> Option<&ModFunctionType<R>>
pub fn as_function_type(&self) -> Option<&ModFunctionType<R>>
Returns Some
if self
is a reference of variant FunctionType
, and None
otherwise.
sourcepub fn as_mut_function_type(&mut self) -> Option<&mut ModFunctionType<R>>
pub fn as_mut_function_type(&mut self) -> Option<&mut ModFunctionType<R>>
Returns Some
if self
is a mutable reference of variant FunctionType
, and None
otherwise.
sourcepub fn expect_function_type(self) -> ModFunctionType<R>where
Self: Debug,
pub fn expect_function_type(self) -> ModFunctionType<R>where
Self: Debug,
Unwraps the value, yielding the content of FunctionType
.
§Panics
Panics if the value is not FunctionType
, with a panic message including the content of self
.
sourcepub fn function_type(self) -> Option<ModFunctionType<R>>
pub fn function_type(self) -> Option<ModFunctionType<R>>
Returns Some
if self
is of variant FunctionType
, and None
otherwise.
Trait Implementations§
source§impl<R> From<ModExpression<R>> for Mod<R>
impl<R> From<ModExpression<R>> for Mod<R>
source§fn from(payload: ModExpression<R>) -> Self
fn from(payload: ModExpression<R>) -> Self
source§impl<R> From<ModFunctionType<R>> for Mod<R>
impl<R> From<ModFunctionType<R>> for Mod<R>
source§fn from(payload: ModFunctionType<R>) -> Self
fn from(payload: ModFunctionType<R>) -> Self
source§impl<R> From<ModInteractive<R>> for Mod<R>
impl<R> From<ModInteractive<R>> for Mod<R>
source§fn from(payload: ModInteractive<R>) -> Self
fn from(payload: ModInteractive<R>) -> Self
impl<R> StructuralPartialEq for Mod<R>
Auto Trait Implementations§
impl<R> Freeze for Mod<R>
impl<R> RefUnwindSafe for Mod<R>where
R: RefUnwindSafe,
impl<R> Send for Mod<R>where
R: Send,
impl<R> Sync for Mod<R>where
R: Sync,
impl<R> Unpin for Mod<R>where
R: Unpin,
impl<R> UnwindSafe for Mod<R>where
R: UnwindSafe,
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