pub struct Template { /* private fields */ }Expand description
Precompiled version of the string template.
Implementations§
Source§impl Template
impl Template
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty template, which can be filled using the builders.
use dfmt::*;
let formatted_string = Template::new()
.literal("Hello, ")
.specified_argument(0, Specifier::default())
.literal("!")
.arguments()
.builder()
.display(0, &"World")
.format()
.unwrap();
println!("{}", formatted_string);Sourcepub fn expect_all_arguments_to_meet_constraints(
&self,
allowed_specifier: &AllowedSpecifier,
) -> Result<&Self, Error>
pub fn expect_all_arguments_to_meet_constraints( &self, allowed_specifier: &AllowedSpecifier, ) -> Result<&Self, Error>
Expects that all arguments meet the specified constraints.
Sourcepub fn expect_argument<K: ToArgumentKey>(
&self,
key: K,
allowed_specifier: &AllowedSpecifier,
) -> Result<&Self, Error>
pub fn expect_argument<K: ToArgumentKey>( &self, key: K, allowed_specifier: &AllowedSpecifier, ) -> Result<&Self, Error>
Expect a specified argument within a parsed template
Sourcepub fn specified_argument<K: ToArgumentKey>(
self,
key: K,
specifier: Specifier,
) -> Self
pub fn specified_argument<K: ToArgumentKey>( self, key: K, specifier: Specifier, ) -> Self
Builder to add an argument with a specifier.
Sourcepub fn argument<K: ToArgumentKey>(self, key: K) -> Self
pub fn argument<K: ToArgumentKey>(self, key: K) -> Self
Builder to add an argument without a specifier.
pub fn argument_type_requirements( &self, argument_key: &ArgumentKey, ) -> Result<&ArgumentTypeRequirements, Error>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Template
impl RefUnwindSafe for Template
impl Send for Template
impl Sync for Template
impl Unpin for Template
impl UnwindSafe for Template
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
Mutably borrows from an owned value. Read more