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
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)