pub struct Context<'a> { /* private fields */ }Expand description
Format context
Implementations§
Source§impl<'a> Context<'a>
impl<'a> Context<'a>
Sourcepub fn format<T, PrefixWs>(
&mut self,
value: &mut T,
prefix_ws: PrefixWs,
) -> FormatOutput
pub fn format<T, PrefixWs>( &mut self, value: &mut T, prefix_ws: PrefixWs, ) -> FormatOutput
Formats a value
Sourcepub fn format_with<T, PrefixWs, A>(
&mut self,
value: &mut T,
prefix_ws: PrefixWs,
args: A,
) -> FormatOutputwhere
T: Format<PrefixWs, A>,
pub fn format_with<T, PrefixWs, A>(
&mut self,
value: &mut T,
prefix_ws: PrefixWs,
args: A,
) -> FormatOutputwhere
T: Format<PrefixWs, A>,
Formats a value with arguments
Sourcepub fn config_mut(&mut self) -> &mut Config
pub fn config_mut(&mut self) -> &mut Config
Returns the config mutably
Sourcepub fn with_indent<O>(&mut self, f: impl FnOnce(&mut Self) -> O) -> O
pub fn with_indent<O>(&mut self, f: impl FnOnce(&mut Self) -> O) -> O
Runs f with a further indentation level
Sourcepub fn with_indent_if<O>(
&mut self,
pred: bool,
f: impl FnOnce(&mut Self) -> O,
) -> O
pub fn with_indent_if<O>( &mut self, pred: bool, f: impl FnOnce(&mut Self) -> O, ) -> O
Runs f with a further indentation level if pred is true
Sourcepub fn without_indent<O>(
&mut self,
f: impl for<'b> FnOnce(&'b mut Self) -> O,
) -> O
pub fn without_indent<O>( &mut self, f: impl for<'b> FnOnce(&'b mut Self) -> O, ) -> O
Runs f with one less indentation level
Sourcepub fn without_indent_if<O>(
&mut self,
pred: bool,
f: impl for<'b> FnOnce(&'b mut Self) -> O,
) -> O
pub fn without_indent_if<O>( &mut self, pred: bool, f: impl for<'b> FnOnce(&'b mut Self) -> O, ) -> O
Runs f with one less indentation level if pred is true, otherwise
runs it with the current indent
Sourcepub fn with_indent_offset<O>(
&mut self,
offset: i16,
f: impl for<'b> FnOnce(&'b mut Self) -> O,
) -> O
pub fn with_indent_offset<O>( &mut self, offset: i16, f: impl for<'b> FnOnce(&'b mut Self) -> O, ) -> O
Runs f with an indentation offset of offset
Sourcepub fn with_indent_offset_if<O>(
&mut self,
offset: i16,
pred: bool,
f: impl for<'b> FnOnce(&'b mut Self) -> O,
) -> O
pub fn with_indent_offset_if<O>( &mut self, offset: i16, pred: bool, f: impl for<'b> FnOnce(&'b mut Self) -> O, ) -> O
Runs f with an indentation offset of offset if pred is true
Sourcepub fn sub_context(&mut self) -> Context<'_>
pub fn sub_context(&mut self) -> Context<'_>
Creates a sub-context.
Sub contexts have their own configuration
Sourcepub fn remove_tag(&mut self, tag: FormatTag) -> bool
pub fn remove_tag(&mut self, tag: FormatTag) -> bool
Removes a tag.
Returns if the tag was present
Sourcepub fn set_tag(&mut self, tag: FormatTag, present: bool) -> bool
pub fn set_tag(&mut self, tag: FormatTag, present: bool) -> bool
Sets whether a tag is present.
Returns if the tag was present
Sourcepub fn with_tag<O>(
&mut self,
tag: FormatTag,
f: impl FnOnce(&mut Self) -> O,
) -> O
pub fn with_tag<O>( &mut self, tag: FormatTag, f: impl FnOnce(&mut Self) -> O, ) -> O
Runs f with a tag, removing it after
Sourcepub fn with_tag_if<O>(
&mut self,
pred: bool,
tag: FormatTag,
f: impl FnOnce(&mut Self) -> O,
) -> O
pub fn with_tag_if<O>( &mut self, pred: bool, tag: FormatTag, f: impl FnOnce(&mut Self) -> O, ) -> O
Runs f with a tag if pred is true, removing it after
Sourcepub fn without_tag<O>(
&mut self,
tag: FormatTag,
f: impl FnOnce(&mut Self) -> O,
) -> O
pub fn without_tag<O>( &mut self, tag: FormatTag, f: impl FnOnce(&mut Self) -> O, ) -> O
Runs f without a tag, adding it after if it existed
Sourcepub fn without_tag_if<O>(
&mut self,
pred: bool,
tag: FormatTag,
f: impl FnOnce(&mut Self) -> O,
) -> O
pub fn without_tag_if<O>( &mut self, pred: bool, tag: FormatTag, f: impl FnOnce(&mut Self) -> O, ) -> O
Runs f without a tag if pred is true, adding it after if it existed
Auto Trait Implementations§
impl<'a> Freeze for Context<'a>
impl<'a> RefUnwindSafe for Context<'a>
impl<'a> Send for Context<'a>
impl<'a> Sync for Context<'a>
impl<'a> Unpin for Context<'a>
impl<'a> UnsafeUnpin for Context<'a>
impl<'a> !UnwindSafe for Context<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more