pub struct Generator<'s, SI: SyntaxInterpreter> { /* private fields */ }Expand description
A helper type that consumes the interpreter and generates the whole code block with it. The
block itself is generated with prelude and postlude callbacks. E.g. for Python this snippet
can be used to generate the interpret method:
ⓘ
record_type
.syntax
.bind(PythonRecordInterpreter::new(&record_type))
.prelude(|intrp, out| {
bufwriteln!(out, :>4, "def interpret(self):");
intrp.offset = 8;
})
// There is no need to use the .postlude(|intrp, out|) callback because
// in Python functions and methods don't have closing brackets or keywords
.generate()?;To construct the generator witt a bind method import BindExt trait.
Implementations§
Auto Trait Implementations§
impl<'s, SI> !RefUnwindSafe for Generator<'s, SI>
impl<'s, SI> !Send for Generator<'s, SI>
impl<'s, SI> !Sync for Generator<'s, SI>
impl<'s, SI> !UnwindSafe for Generator<'s, SI>
impl<'s, SI> Freeze for Generator<'s, SI>where
SI: Freeze,
impl<'s, SI> Unpin for Generator<'s, SI>where
SI: Unpin,
impl<'s, SI> UnsafeUnpin for Generator<'s, SI>where
SI: UnsafeUnpin,
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