| Crates.io | late_format |
| lib.rs | late_format |
| version | 1.0.0 |
| created_at | 2023-10-23 12:31:32.781201+00 |
| updated_at | 2023-10-23 12:31:32.781201+00 |
| description | Late formatting of string parameters |
| homepage | |
| repository | https://github.com/hydroper/rust_late_format |
| max_upload_size | |
| id | 1011284 |
| size | 5,277 |
This crate provides a simple way of formatting parameters in a runtime string, with runtime parameter names.
This is an alternative to using complex template engines.
use late_format::LateFormat;
use maplit::hashmap;
let user_string: String = "some user string: {id}".into();
assert_eq!(
"some user string: x",
user_string.late_format(hashmap!{"id".into() => "x".into()})
);
let user_string: String = r#"some user string: {"id"}"#.into();
assert_eq!(
"some user string: id",
user_string.late_format(hashmap!{"id".into() => "x".into()})
);
let user_string: String = r#"some user string: { "id" }"#.into();
assert_eq!(
"some user string: id",
user_string.late_format(hashmap!{"id".into() => "x".into()})
);
let user_string: String = "some user string: {id}".into();
assert_eq!(
"some user string: None",
user_string.late_format(hashmap!{})
);