pub enum GenericArg<'tcx> {
Lifetime(Region),
Type(Ty<'tcx>),
Const(ConstantExpr<'tcx>),
}Expand description
Reflects both [ty::GenericArg] and [ty::GenericArgKind]
Variants§
Implementations§
Source§impl<'tcx> GenericArg<'tcx>
impl<'tcx> GenericArg<'tcx>
Sourcepub fn is_lifetime(&self) -> bool
pub fn is_lifetime(&self) -> bool
Returns true if this is a GenericArg::Lifetime, otherwise false
Sourcepub fn as_lifetime_mut(&mut self) -> Option<&mut Region>
pub fn as_lifetime_mut(&mut self) -> Option<&mut Region>
Optionally returns mutable references to the inner fields if this is a GenericArg::Lifetime, otherwise None
Sourcepub fn as_lifetime(&self) -> Option<&Region>
pub fn as_lifetime(&self) -> Option<&Region>
Optionally returns references to the inner fields if this is a GenericArg::Lifetime, otherwise None
Sourcepub fn into_lifetime(self) -> Result<Region, Self>
pub fn into_lifetime(self) -> Result<Region, Self>
Returns the inner fields if this is a GenericArg::Lifetime, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_lifetime_unchecked(self) -> Region
pub unsafe fn into_lifetime_unchecked(self) -> Region
Unchecked return of the inner fields of GenericArg::Lifetime.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_lifetime_unchecked(&self) -> &Region
pub unsafe fn as_lifetime_unchecked(&self) -> &Region
Unchecked reference of the inner fields of GenericArg::Lifetime.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_lifetime_mut_unchecked(&mut self) -> &mut Region
pub unsafe fn as_lifetime_mut_unchecked(&mut self) -> &mut Region
Unchecked mutable reference of the inner fields of GenericArg::Lifetime.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub fn as_type_mut(&mut self) -> Option<&mut Ty<'tcx>>
pub fn as_type_mut(&mut self) -> Option<&mut Ty<'tcx>>
Optionally returns mutable references to the inner fields if this is a GenericArg::Type, otherwise None
Sourcepub fn as_type(&self) -> Option<&Ty<'tcx>>
pub fn as_type(&self) -> Option<&Ty<'tcx>>
Optionally returns references to the inner fields if this is a GenericArg::Type, otherwise None
Sourcepub fn into_type(self) -> Result<Ty<'tcx>, Self>
pub fn into_type(self) -> Result<Ty<'tcx>, Self>
Returns the inner fields if this is a GenericArg::Type, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_type_unchecked(self) -> Ty<'tcx>
pub unsafe fn into_type_unchecked(self) -> Ty<'tcx>
Unchecked return of the inner fields of GenericArg::Type.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_type_unchecked(&self) -> &Ty<'tcx>
pub unsafe fn as_type_unchecked(&self) -> &Ty<'tcx>
Unchecked reference of the inner fields of GenericArg::Type.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_type_mut_unchecked(&mut self) -> &mut Ty<'tcx>
pub unsafe fn as_type_mut_unchecked(&mut self) -> &mut Ty<'tcx>
Unchecked mutable reference of the inner fields of GenericArg::Type.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub fn as_const_mut(&mut self) -> Option<&mut ConstantExpr<'tcx>>
pub fn as_const_mut(&mut self) -> Option<&mut ConstantExpr<'tcx>>
Optionally returns mutable references to the inner fields if this is a GenericArg::Const, otherwise None
Sourcepub fn as_const(&self) -> Option<&ConstantExpr<'tcx>>
pub fn as_const(&self) -> Option<&ConstantExpr<'tcx>>
Optionally returns references to the inner fields if this is a GenericArg::Const, otherwise None
Sourcepub fn into_const(self) -> Result<ConstantExpr<'tcx>, Self>
pub fn into_const(self) -> Result<ConstantExpr<'tcx>, Self>
Returns the inner fields if this is a GenericArg::Const, otherwise returns back the enum in the Err case of the result
Sourcepub unsafe fn into_const_unchecked(self) -> ConstantExpr<'tcx>
pub unsafe fn into_const_unchecked(self) -> ConstantExpr<'tcx>
Unchecked return of the inner fields of GenericArg::Const.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_const_unchecked(&self) -> &ConstantExpr<'tcx>
pub unsafe fn as_const_unchecked(&self) -> &ConstantExpr<'tcx>
Unchecked reference of the inner fields of GenericArg::Const.
§Safety
Results in undefined behavior when it is the incorrect variant.
Sourcepub unsafe fn as_const_mut_unchecked(&mut self) -> &mut ConstantExpr<'tcx>
pub unsafe fn as_const_mut_unchecked(&mut self) -> &mut ConstantExpr<'tcx>
Unchecked mutable reference of the inner fields of GenericArg::Const.
§Safety
Results in undefined behavior when it is the incorrect variant.
Trait Implementations§
Source§impl<'tcx> Clone for GenericArg<'tcx>
impl<'tcx> Clone for GenericArg<'tcx>
Source§fn clone(&self) -> GenericArg<'tcx>
fn clone(&self) -> GenericArg<'tcx>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'tcx> Debug for GenericArg<'tcx>
impl<'tcx> Debug for GenericArg<'tcx>
impl<'tcx> Eq for GenericArg<'tcx>
Source§impl<'tcx> Hash for GenericArg<'tcx>
impl<'tcx> Hash for GenericArg<'tcx>
Source§impl<'tcx> PartialEq for GenericArg<'tcx>
impl<'tcx> PartialEq for GenericArg<'tcx>
Source§impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, GenericArg<'tcx>> for GenericArgKind<'tcx>
impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, GenericArg<'tcx>> for GenericArgKind<'tcx>
fn sinto(&self, s: &S) -> GenericArg<'tcx>
Source§impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, GenericArg<'tcx>> for GenericArg<'tcx>
impl<'tcx, S: UnderOwnerState<'tcx>> SInto<S, GenericArg<'tcx>> for GenericArg<'tcx>
fn sinto(&self, s: &S) -> GenericArg<'tcx>
impl<'tcx> StructuralPartialEq for GenericArg<'tcx>
Auto Trait Implementations§
impl<'tcx> DynSend for GenericArg<'tcx>
impl<'tcx> DynSync for GenericArg<'tcx>
impl<'tcx> Freeze for GenericArg<'tcx>
impl<'tcx> RefUnwindSafe for GenericArg<'tcx>
impl<'tcx> Send for GenericArg<'tcx>
impl<'tcx> Sync for GenericArg<'tcx>
impl<'tcx> Unpin for GenericArg<'tcx>
impl<'tcx> UnsafeUnpin for GenericArg<'tcx>
impl<'tcx> UnwindSafe for GenericArg<'tcx>
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,
impl<T> Dedup for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> HashConsable for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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