RonFormatter

Struct RonFormatter 

Source
pub struct RonFormatter<'a> { /* private fields */ }
Expand description

Internal formatter state.

Implementations§

Source§

impl<'a> RonFormatter<'a>

Source

pub fn format_seq_items(&mut self, seq: &SeqExpr<'_>)

Format sequence items directly from AST (no allocation).

Source

pub fn format_tuple_items(&mut self, tuple: &TupleExpr<'_>)

Format tuple elements directly from AST - TupleExpr variant (no allocation).

Source

pub fn format_tuple_body(&mut self, tuple: &TupleBody<'_>)

Format tuple elements directly from AST - TupleBody variant (no allocation).

Source

pub fn format_map_items(&mut self, map: &MapExpr<'_>)

Format map entries directly from AST (no allocation).

Source

pub fn format_anon_struct_items(&mut self, s: &AnonStructExpr<'_>)

Format anonymous struct fields directly from AST (no allocation).

Source

pub fn format_fields_body(&mut self, fields: &FieldsBody<'_>)

Format struct fields directly from AST - FieldsBody variant (no allocation).

Source

pub fn format_seq_slice<'t, T>( &mut self, leading: &Trivia<'_>, trailing: &Trivia<'_>, items: &[(ItemTrivia<'t>, &'t T)], )
where T: SerializeRon + 't,

Format a sequence [a, b, c] from a pre-collected slice.

Source

pub fn format_seq_with<'t, T, I>( &mut self, leading: Option<&Trivia<'_>>, trailing: Option<&Trivia<'_>>, items: I, )
where T: SerializeRon + 't, I: IntoIterator<Item = (ItemTrivia<'t>, &'t T)>,

Format a sequence [a, b, c] using SerializeRon and ItemTrivia.

Source

pub fn format_tuple_slice<'t, T>( &mut self, leading: &Trivia<'_>, trailing: &Trivia<'_>, items: &[(ItemTrivia<'t>, &'t T)], )
where T: SerializeRon + 't,

Format a tuple (a, b, c) from a pre-collected slice.

Source

pub fn format_tuple_with<'t, T, I>( &mut self, leading: Option<&Trivia<'_>>, trailing: Option<&Trivia<'_>>, items: I, )
where T: SerializeRon + 't, I: IntoIterator<Item = (ItemTrivia<'t>, &'t T)>,

Format a tuple (a, b, c) using SerializeRon and ItemTrivia.

Source

pub fn format_map_slice<'t, K, V>( &mut self, leading: &Trivia<'_>, trailing: &Trivia<'_>, entries: &[(ItemTrivia<'t>, &'t K, &'t V)], )
where K: SerializeRon + 't, V: SerializeRon + 't,

Format a map {k: v, ...} from a pre-collected slice.

Source

pub fn format_map_with<'t, K, V, I>( &mut self, leading: Option<&Trivia<'_>>, trailing: Option<&Trivia<'_>>, entries: I, )
where K: SerializeRon + 't, V: SerializeRon + 't, I: IntoIterator<Item = (ItemTrivia<'t>, &'t K, &'t V)>,

Format a map {k: v, ...} using SerializeRon and ItemTrivia.

Source

pub fn format_anon_struct_slice<'t, V>( &mut self, leading: &Trivia<'_>, trailing: &Trivia<'_>, fields: &[(ItemTrivia<'t>, &'t str, &'t V)], )
where V: SerializeRon + 't,

Format an anonymous struct (x: 1, y: 2) from a pre-collected slice.

Source

pub fn format_anon_struct_with<'t, V, I>( &mut self, leading: Option<&Trivia<'_>>, trailing: Option<&Trivia<'_>>, fields: I, )
where V: SerializeRon + 't, I: IntoIterator<Item = (ItemTrivia<'t>, &'t str, &'t V)>,

Format an anonymous struct (x: 1, y: 2) using field name as &str.

Source

pub fn format_struct_fields_with<'t, V, I>( &mut self, leading: Option<&Trivia<'_>>, trailing: Option<&Trivia<'_>>, fields: I, )
where V: SerializeRon + 't, I: IntoIterator<Item = (ItemTrivia<'t>, &'t str, &'t V)>, I::IntoIter: Clone,

Format struct fields body (x: 1, y: 2) for named structs.

Source

pub fn format_option_with<T: SerializeRon>( &mut self, value: Option<(&T, ItemTrivia<'_>)>, )

Format Option: Some(value) or None.

Source

pub fn write_str(&mut self, s: &str)

Write a string to the output.

Source

pub fn write_char(&mut self, c: char)

Write a character to the output.

Source

pub fn write_fmt(&mut self, args: Arguments<'_>)

Write formatted data to the output (implements core::fmt::Write).

Source

pub fn format_char_value(&mut self, c: char)

Format a char value with proper escaping.

Source

pub fn format_string_value(&mut self, s: &str)

Format a string value with proper escaping.

Source

pub fn format_bytes_value(&mut self, bytes: &[u8])

Format a byte string value with proper escaping.

Auto Trait Implementations§

§

impl<'a> Freeze for RonFormatter<'a>

§

impl<'a> RefUnwindSafe for RonFormatter<'a>

§

impl<'a> Send for RonFormatter<'a>

§

impl<'a> Sync for RonFormatter<'a>

§

impl<'a> Unpin for RonFormatter<'a>

§

impl<'a> UnwindSafe for RonFormatter<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.