pub struct Impl<'a, P: Parent> { /* private fields */ }
Expand description
A helper struct for implementing functions for a given struct or enum.
Implementations§
source§impl<'a, P: Parent> Impl<'a, P>
impl<'a, P: Parent> Impl<'a, P>
sourcepub fn generate_fn(&mut self, name: impl Into<String>) -> FnBuilder<'_, Self>
pub fn generate_fn(&mut self, name: impl Into<String>) -> FnBuilder<'_, Self>
source§impl<'a> Impl<'a, Generator>
impl<'a> Impl<'a, Generator>
sourcepub fn modify_generic_constraints<CB>(&mut self, cb: CB) -> &mut Self
pub fn modify_generic_constraints<CB>(&mut self, cb: CB) -> &mut Self
Modify the generic constraints of a type. This can be used to add additional type constraints to your implementation.
ⓘ
// Your derive:
#[derive(YourTrait)]
pub struct Foo<B> {
...
}
// With this code:
generator
.r#impl()
.modify_generic_constraints(|generics, constraints| {
for g in generics.iter_generics() {
constraints.push_generic(g, "YourTrait");
}
})
// will generate:
impl<B> Foo<B>
where B: YourTrait // <-
{
}
Note that this function is only implemented when you call .r#impl
on Generator
.
Trait Implementations§
Auto Trait Implementations§
impl<'a, P> Freeze for Impl<'a, P>
impl<'a, P> RefUnwindSafe for Impl<'a, P>where
P: RefUnwindSafe,
impl<'a, P> !Send for Impl<'a, P>
impl<'a, P> !Sync for Impl<'a, P>
impl<'a, P> Unpin for Impl<'a, P>
impl<'a, P> !UnwindSafe for Impl<'a, P>
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