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.
Trait Implementations§
source§impl<R> From<TypeParamParamSpec<R>> for TypeParam<R>
impl<R> From<TypeParamParamSpec<R>> for TypeParam<R>
source§fn from(payload: TypeParamParamSpec<R>) -> Self
fn from(payload: TypeParamParamSpec<R>) -> Self
source§impl<R> From<TypeParamTypeVar<R>> for TypeParam<R>
impl<R> From<TypeParamTypeVar<R>> for TypeParam<R>
source§fn from(payload: TypeParamTypeVar<R>) -> Self
fn from(payload: TypeParamTypeVar<R>) -> Self
source§impl<R> From<TypeParamTypeVarTuple<R>> for TypeParam<R>
impl<R> From<TypeParamTypeVarTuple<R>> for TypeParam<R>
source§fn from(payload: TypeParamTypeVarTuple<R>) -> Self
fn from(payload: TypeParamTypeVarTuple<R>) -> Self
impl<R> StructuralPartialEq for TypeParam<R>
Auto Trait Implementations§
impl<R> Freeze for TypeParam<R>where
R: Freeze,
impl<R> RefUnwindSafe for TypeParam<R>where
R: RefUnwindSafe,
impl<R> Send for TypeParam<R>where
R: Send,
impl<R> Sync for TypeParam<R>where
R: Sync,
impl<R> Unpin for TypeParam<R>where
R: Unpin,
impl<R> UnwindSafe for TypeParam<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