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 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> {}
- The struct is
trait_nameshould 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.
