pub struct Template { /* private fields */ }
Expand description

String templating with std::fmt syntax.

Example

use formatx::Template;

let mut template = "{percentage:.2}".parse::<Template>().unwrap();
template.replace("percentage", 67.7892);
assert_eq!(template.text().unwrap(), "67.79");

Implementations

Create a new instance of format_template::Template.

Example
use formatx::Template;

let template = Template::new("{percentage:.2}").unwrap();

Checks wheter template contains placeholder or not.

Returns unchecked formatted template. For Result version of fomatted template use .text method.

Checks wheter all placeholders are replaced or not and returns formatted template.

Replace a template placeholder with a value. This change is inplace.

Replace a template positional placeholder with a value. This change is inplace.

Replace a template placeholder from a callback String. This change is inplace.

Replace a template placeholder with a value and do additional formatting using callback. This change is inplace.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.