pub enum GenericParamDefKind {
Lifetime {
outlives: Vec<String>,
},
Type {
bounds: Vec<GenericBound>,
default: Option<Type>,
is_synthetic: bool,
},
Const {
type_: Type,
default: Option<String>,
},
}
Expand description
The kind of a GenericParamDef
.
Variants§
Lifetime
Denotes a lifetime parameter.
Fields
Type
Denotes a type parameter.
Fields
bounds: Vec<GenericBound>
Bounds applied directly to the type. Note that the bounds from where
clauses
that constrain this parameter won’t appear here.
fn default2<T: Default>() -> [T; 2] where T: Clone { todo!() }
// ^^^^^^^
default: Option<Type>
The default type for this parameter, if provided, e.g.
trait PartialEq<Rhs = Self> {}
// ^^^^
is_synthetic: bool
This is normally false
, which means that this generic parameter is
declared in the Rust source text.
If it is true
, this generic parameter has been introduced by the
compiler behind the scenes.
§Example
Consider
pub fn f(_: impl Trait) {}
The compiler will transform this behind the scenes to
pub fn f<impl Trait: Trait>(_: impl Trait) {}
In this example, the generic parameter named impl Trait
(and which
is bound by Trait
) is synthetic, because it was not originally in
the Rust source text.
Const
Denotes a constant parameter.
Trait Implementations§
source§impl Clone for GenericParamDefKind
impl Clone for GenericParamDefKind
source§fn clone(&self) -> GenericParamDefKind
fn clone(&self) -> GenericParamDefKind
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for GenericParamDefKind
impl Debug for GenericParamDefKind
source§impl<'de> Deserialize<'de> for GenericParamDefKind
impl<'de> Deserialize<'de> for GenericParamDefKind
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Hash for GenericParamDefKind
impl Hash for GenericParamDefKind
source§impl PartialEq for GenericParamDefKind
impl PartialEq for GenericParamDefKind
source§impl Serialize for GenericParamDefKind
impl Serialize for GenericParamDefKind
impl Eq for GenericParamDefKind
impl StructuralPartialEq for GenericParamDefKind
Auto Trait Implementations§
impl Freeze for GenericParamDefKind
impl RefUnwindSafe for GenericParamDefKind
impl Send for GenericParamDefKind
impl Sync for GenericParamDefKind
impl Unpin for GenericParamDefKind
impl UnwindSafe for GenericParamDefKind
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 112 bytes
Size for each variant:
Lifetime
: 32 bytesType
: 112 bytesConst
: 112 bytes