Skip to main content

Formattable

Trait Formattable 

Source
pub trait Formattable {
    // Required methods
    fn with_prefix_ws<O>(
        &mut self,
        ctx: &mut Context<'_>,
        f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O,
    ) -> Result<O, ControlFlow<()>>;
    fn with_strings<O>(
        &mut self,
        ctx: &mut Context<'_>,
        exclude_prefix_ws: bool,
        f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>,
    ) -> ControlFlow<O, bool>;
    fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput;

    // Provided methods
    fn prefix_ws_is_pure(&mut self, ctx: &mut Context<'_>) -> Option<bool> { ... }
    fn prefix_ws_join_prefix(
        &mut self,
        ctx: &mut Context<'_>,
        ws: Whitespace,
    ) -> Result<(), Whitespace> { ... }
}
Expand description

Formattable types

Required Methods§

Source

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Accesses the prefix whitespace of this type.

§Return
  • Ok() if the prefix whitespace was found.
  • Err(Break(())) if no prefix whitespace existed and the type wasn’t empty
  • Err(Continue(())) if no prefix whitespace existed but the type was empty.
Source

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Iterates over all strings in this type.

§Returns
  • Break() if f returned Break()
  • Continue(true) if this type was empty.
  • Continue(false) if this type was non-empty.
Source

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Returns the formatting output for this type, without formatting it.

Provided Methods§

Source

fn prefix_ws_is_pure(&mut self, ctx: &mut Context<'_>) -> Option<bool>

Returns if the prefix whitespace is pure.

Source

fn prefix_ws_join_prefix( &mut self, ctx: &mut Context<'_>, ws: Whitespace, ) -> Result<(), Whitespace>

Joins a string as a prefix onto the prefix whitespace of this type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Formattable for !

Source§

fn with_prefix_ws<O>( &mut self, _ctx: &mut Context<'_>, _f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, _ctx: &mut Context<'_>, _exclude_prefix_ws: bool, _f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, _ctx: &mut Context<'_>) -> FormatOutput

Source§

impl Formattable for ()

Source§

fn with_prefix_ws<O>( &mut self, _ctx: &mut Context<'_>, _f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, _ctx: &mut Context<'_>, _exclude_prefix_ws: bool, _f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, _ctx: &mut Context<'_>) -> FormatOutput

Source§

impl Formattable for AstStr

Source§

fn with_prefix_ws<O>( &mut self, _ctx: &mut Context<'_>, _f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, _exclude_prefix_ws: bool, f: &mut impl FnMut(&mut Self, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, _ctx: &mut Context<'_>) -> FormatOutput

Source§

impl Formattable for Whitespace

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Self, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T0: Formattable> Formattable for (T0,)

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T0: Formattable, T1: Formattable> Formattable for (T0, T1)

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T0: Formattable, T1: Formattable, T2: Formattable> Formattable for (T0, T1, T2)

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T> Formattable for PhantomData<T>

Source§

fn with_prefix_ws<O>( &mut self, _ctx: &mut Context<'_>, _f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, _ctx: &mut Context<'_>, _exclude_prefix_ws: bool, _f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, _ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T: ArenaData + Formattable> Formattable for ArenaIdx<T>

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T: Formattable> Formattable for Option<T>

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T: Formattable> Formattable for &mut T

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T: Formattable> Formattable for Box<T>

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Source§

impl<T: Formattable> Formattable for Vec<T>

Source§

fn with_prefix_ws<O>( &mut self, ctx: &mut Context<'_>, f: &mut impl FnMut(&mut Whitespace, &mut Context<'_>) -> O, ) -> Result<O, ControlFlow<()>>

Source§

fn with_strings<O>( &mut self, ctx: &mut Context<'_>, exclude_prefix_ws: bool, f: &mut impl FnMut(&mut AstStr, &mut Context<'_>) -> ControlFlow<O>, ) -> ControlFlow<O, bool>

Source§

fn format_output(&mut self, ctx: &mut Context<'_>) -> FormatOutput

Implementors§