[−][src]Struct darklua_core::LuaGenerator
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.
Implementations
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 merge_char(&mut self, character: char)
[src]
This function pushes a character into the string, without appending a new line or a space between the last pushed content.
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]
&mut self,
vector: &Vec<T>,
for_each: F,
between: G
) where
F: FnMut(&mut Self, &T),
G: FnMut(&mut Self),
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.
pub fn push_str_and_break_if<F>(&mut self, content: &str, predicate: F) where
F: Fn(&str) -> bool,
[src]
F: Fn(&str) -> bool,
This function only insert a space or a new line if the given predicate returns true. In the other case, the string is added to the current generator content.
pub fn push_char_and_break_if<F>(&mut self, character: char, predicate: F) where
F: Fn(&str) -> bool,
[src]
F: Fn(&str) -> bool,
This function only insert a space or a new line if the given predicate returns true. In the other case, the character is added to the current generator content.
Trait Implementations
impl Default for LuaGenerator
[src]
Auto Trait Implementations
impl RefUnwindSafe for LuaGenerator
impl Send for LuaGenerator
impl Sync for LuaGenerator
impl Unpin for LuaGenerator
impl UnwindSafe for LuaGenerator
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,