Enum rustpython_ast::TypeParam
source · pub enum TypeParam<R = TextRange> {
TypeVar(TypeParamTypeVar<R>),
ParamSpec(TypeParamParamSpec<R>),
TypeVarTuple(TypeParamTypeVarTuple<R>),
}
Expand description
See also type_param
Variants§
TypeVar(TypeParamTypeVar<R>)
ParamSpec(TypeParamParamSpec<R>)
TypeVarTuple(TypeParamTypeVarTuple<R>)
Implementations§
source§impl<R> TypeParam<R>
impl<R> TypeParam<R>
sourcepub const fn is_type_var(&self) -> bool
pub const fn is_type_var(&self) -> bool
Returns true
if self
is of variant TypeVar
.
sourcepub fn as_type_var(&self) -> Option<&TypeParamTypeVar<R>>
pub fn as_type_var(&self) -> Option<&TypeParamTypeVar<R>>
Returns Some
if self
is a reference of variant TypeVar
, and None
otherwise.
sourcepub fn as_mut_type_var(&mut self) -> Option<&mut TypeParamTypeVar<R>>
pub fn as_mut_type_var(&mut self) -> Option<&mut TypeParamTypeVar<R>>
Returns Some
if self
is a mutable reference of variant TypeVar
, and None
otherwise.
sourcepub fn expect_type_var(self) -> TypeParamTypeVar<R>where
Self: Debug,
pub fn expect_type_var(self) -> TypeParamTypeVar<R>where
Self: Debug,
sourcepub fn type_var(self) -> Option<TypeParamTypeVar<R>>
pub fn type_var(self) -> Option<TypeParamTypeVar<R>>
Returns Some
if self
is of variant TypeVar
, and None
otherwise.
sourcepub const fn is_param_spec(&self) -> bool
pub const fn is_param_spec(&self) -> bool
Returns true
if self
is of variant ParamSpec
.
sourcepub fn as_param_spec(&self) -> Option<&TypeParamParamSpec<R>>
pub fn as_param_spec(&self) -> Option<&TypeParamParamSpec<R>>
Returns Some
if self
is a reference of variant ParamSpec
, and None
otherwise.
sourcepub fn as_mut_param_spec(&mut self) -> Option<&mut TypeParamParamSpec<R>>
pub fn as_mut_param_spec(&mut self) -> Option<&mut TypeParamParamSpec<R>>
Returns Some
if self
is a mutable reference of variant ParamSpec
, and None
otherwise.
sourcepub fn expect_param_spec(self) -> TypeParamParamSpec<R>where
Self: Debug,
pub fn expect_param_spec(self) -> TypeParamParamSpec<R>where
Self: Debug,
sourcepub fn param_spec(self) -> Option<TypeParamParamSpec<R>>
pub fn param_spec(self) -> Option<TypeParamParamSpec<R>>
Returns Some
if self
is of variant ParamSpec
, and None
otherwise.
sourcepub const fn is_type_var_tuple(&self) -> bool
pub const fn is_type_var_tuple(&self) -> bool
Returns true
if self
is of variant TypeVarTuple
.
sourcepub fn as_type_var_tuple(&self) -> Option<&TypeParamTypeVarTuple<R>>
pub fn as_type_var_tuple(&self) -> Option<&TypeParamTypeVarTuple<R>>
Returns Some
if self
is a reference of variant TypeVarTuple
, and None
otherwise.
sourcepub fn as_mut_type_var_tuple(&mut self) -> Option<&mut TypeParamTypeVarTuple<R>>
pub fn as_mut_type_var_tuple(&mut self) -> Option<&mut TypeParamTypeVarTuple<R>>
Returns Some
if self
is a mutable reference of variant TypeVarTuple
, and None
otherwise.
sourcepub fn expect_type_var_tuple(self) -> TypeParamTypeVarTuple<R>where
Self: Debug,
pub fn expect_type_var_tuple(self) -> TypeParamTypeVarTuple<R>where
Self: Debug,
Unwraps the value, yielding the content of TypeVarTuple
.
§Panics
Panics if the value is not TypeVarTuple
, with a panic message including the content of self
.
sourcepub fn type_var_tuple(self) -> Option<TypeParamTypeVarTuple<R>>
pub fn type_var_tuple(self) -> Option<TypeParamTypeVarTuple<R>>
Returns Some
if self
is of variant TypeVarTuple
, and None
otherwise.