[][src]Struct darklua_core::LuaGenerator

pub struct LuaGenerator { /* fields omitted */ }

A struct to control how the Lua code is generated. Content can be pushed into the generator and it will automatically add spaces when necessary.

Methods

impl LuaGenerator[src]

pub fn new(column_span: usize) -> Self[src]

Creates a generator that will wrap the code on a new line after the amount of characters given by the column_span argument.

pub fn push_str(&mut self, content: &str)[src]

Appends a string to the current content of the LuaGenerator. A space may be added depending of the last character of the current content and the first character pushed.

pub fn push_char(&mut self, character: char)[src]

Same as the push_str function, but for a single character.

pub fn push_char_force_without_space(&mut self, character: char)[src]

This function pushes a character into the string, without appending a new line character if the line is about to exceed the column span amount.

pub fn into_string(self) -> String[src]

Consumes the LuaGenerator and produce a String object.

pub fn for_each_and_between<T, F, G>(
    &mut self,
    vector: &Vec<T>,
    for_each: F,
    between: G
) where
    F: FnMut(&mut Self, &T),
    G: FnMut(&mut Self), 
[src]

A utility function to iterate on a vector and call the for_each function with each element of the vector and the between function between each element. It is useful when generating lists separated with a comma.

Trait Implementations

impl Default for LuaGenerator[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.