Struct virtue::generate::Generator[][src]

pub struct Generator { /* fields omitted */ }
Expand description

The generator is used to generate code.

Often you will want to use impl_for to generate an impl <trait_name> for <target_name()>.

Implementations

Return the name for the struct or enum that this is going to be implemented on.

Generate an impl <target_name> implementation. See Impl for more information.

Generate an impl <target_name> implementation. See Impl for more information.

Alias for impl which doesn’t need a r# prefix.

Generate an for <trait_name> for <target_name> implementation. See ImplFor for more information.

Generate an for <..lifetimes> <trait_name> for <target_name> implementation. See ImplFor for more information.

Note:

  • Lifetimes should not have the leading apostrophe.
  • The lifetimes passed to this function will automatically depend on any other lifetime this struct or enum may have. Example:
    • The struct is struct Foo<'a> {}
    • You call `generator.impl_for_with_lifetime(“Bar”, &[“b”])
    • The code will be impl<'a, 'b: 'a> Bar<'b> for Foo<'a> {}
  • trait_name should not have custom lifetimes. These will be added automatically.
generator.impl_for_with_lifetimes("Foo", &["a", "b"]);

// will output:
// impl<'a, 'b> Foo<'a, 'b> for StructOrEnum { }

Consume the contents of this generator. This must be called, or else the generator will panic on drop.

Trait Implementations

Executes the destructor for this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.