BoundedGenericParams

Struct BoundedGenericParams 

Source
pub struct BoundedGenericParams {
    pub params: Vec<BoundedGenericParam>,
}
Expand description

Stores different representations of generic parameters for implementing traits.

This structure separates generic parameters into different formats needed when generating trait implementations.

Fields§

§params: Vec<BoundedGenericParam>

Collection of generic parameters with their bounds

Implementations§

Source§

impl BoundedGenericParams

Source

pub fn as_phantom_data(&self) -> AsPhantomData<'_>

Returns a display wrapper that formats generic parameters as a PhantomData type

Source§

impl BoundedGenericParams

Source

pub fn display_with_bounds(&self) -> WithBounds<'_>

Returns a display wrapper that formats generic parameters with their bounds

Source

pub fn display_without_bounds(&self) -> WithoutBounds<'_>

Returns a display wrapper that formats generic parameters without their bounds

Source

pub fn display_as_phantom_data(&self) -> AsPhantomData<'_>

Returns a display wrapper that formats generic parameters as a PhantomData

This is a convenience method for generating PhantomData expressions for use in trait implementations.

§Example

For generic parameters <'a, T, const N: usize>, this returns a wrapper that when displayed produces: ::core::marker::PhantomData<(*mut &'a (), T, [u32; N])>

Source

pub fn with(&self, param: BoundedGenericParam) -> BoundedGenericParams

Adds a new generic parameter in the correct position (lifetimes, then types, then consts)

Source

pub fn with_lifetime(&self, name: LifetimeName) -> BoundedGenericParams

Adds a new lifetime parameter with the given name without bounds

This is a convenience method for adding a lifetime parameter that’s commonly used in trait implementations.

Source

pub fn with_type(&self, name: TokenStream) -> BoundedGenericParams

Adds a new type parameter with the given name without bounds

This is a convenience method for adding a type parameter that’s commonly used in trait implementations.

Source§

impl BoundedGenericParams

Source

pub fn parse(generics: Option<&GenericParams>) -> BoundedGenericParams

Parses generic parameters into separate components for implementing traits.

This method takes a generic parameter declaration and populates the BoundedGenericParams struct with different representations of the generic parameters needed for code generation.

§Examples

For a type like struct Example<T: Clone, 'a, const N: usize>, this would populate: params with entries for each parameter and their bounds.

Trait Implementations§

Source§

impl Clone for BoundedGenericParams

Source§

fn clone(&self) -> BoundedGenericParams

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.