Trait ToString

Source
pub trait ToString {
    // Required methods
    fn push(&mut self, chr: char);
    fn push_new_line(&mut self);
    fn push_str(&mut self, string: &str);
    fn push_str_contains_new_line(&mut self, string: &str);
    fn add_mapping(&mut self, source_span: &SpanWithSource);
    fn characters_on_current_line(&self) -> u32;

    // Provided methods
    fn should_halt(&self) -> bool { ... }
    fn is_counting(&self) -> bool { ... }
}
Expand description

A trait for defining behavior of adding content to a buffer. As well as register markers for source maps

Required Methods§

Source

fn push(&mut self, chr: char)

Append character

Source

fn push_new_line(&mut self)

Append a new line character

Source

fn push_str(&mut self, string: &str)

Use ToString::push_str_contains_new_line if string could contain new lines

Source

fn push_str_contains_new_line(&mut self, string: &str)

Used to push strings that may contain new lines

Source

fn add_mapping(&mut self, source_span: &SpanWithSource)

Adds a mapping of the from a original position in the source to the position in the current buffer

Should be called before adding new content

Source

fn characters_on_current_line(&self) -> u32

Provided Methods§

Source

fn should_halt(&self) -> bool

Some implementors might not ToString the whole input. This signals for users to end early as further usage of this trait has no effect

Source

fn is_counting(&self) -> bool

Implementations on Foreign Types§

Source§

impl ToString for String

Source§

fn push(&mut self, chr: char)

Source§

fn push_new_line(&mut self)

Source§

fn push_str(&mut self, string: &str)

Source§

fn push_str_contains_new_line(&mut self, string: &str)

Source§

fn add_mapping(&mut self, _source_span: &SpanWithSource)

Source§

fn characters_on_current_line(&self) -> u32

Implementors§