Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,24 @@
///
/// The resulting string is `hex(42) = 0x2a`.
///
/// The rules for the specifiers are exactly the same as Rust's [standard formatting syntax](std::fmt).
/// The rules for the specifiers are exactly the same as Rust's [standard formatting syntax](std::fmt),
/// with one exception: specifying width and precision with a variable has a different syntax,
/// since these macros don't take arguments in the same way. It uses the same `$` notation, but is
/// limited to positional references (no `w=width` and `w$`), and the argument comes inside the
/// brackets, separated by a comma from the name of the displayed object. The argument can be any
/// value expression.
///
/// ```
/// let name = "World";
/// let width = 8;
///
/// # let s =
/// fmtools::fmt!("Hello "{name,width:<1$}"!");
/// # let s = s.to_string();
/// # assert_eq!(s, "Hello World !");
/// ```
///
/// The resulting string is `Hello world !` (_i.e._, `Hello world⎵⎵⎵!`).
///
/// ### Let bindings
///
Expand Down