dynfmt::curly

Struct SimpleCurlyFormat

Source
pub struct SimpleCurlyFormat;
Expand description

Format implementation for simple curly brace based format strings.

This syntax is a subset of what Python 3, Rust, .NET and many logging libraries use. Each argument is formated in display mode.

  1. {}: Refers to the next positional argument.
  2. {0}: Refers to the argument at index 0.
  3. {name}: Refers to the named argument with key "name".

§Example

use dynfmt::{Format, SimpleCurlyFormat};

let formatted = SimpleCurlyFormat.format("hello, {}", &["world"]);
assert_eq!("hello, world", formatted.expect("formatting failed"));

Trait Implementations§

Source§

impl Debug for SimpleCurlyFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'f> Format<'f> for SimpleCurlyFormat

Source§

type Iter = SimpleCurlyIter<'f>

The iterator returned by iter_args.
Source§

fn iter_args(&self, format: &'f str) -> Result<Self::Iter, Error<'f>>

Returns an iterator over format arguments in the format string. Read more
Source§

fn format<A>( &self, format: &'f str, arguments: A, ) -> Result<Cow<'f, str>, Error<'f>>
where A: FormatArgs,

Formats the given string with the specified arguments. Read more

Auto Trait Implementations§

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.