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.