| Crates.io | realhydroper-lateformat |
| lib.rs | realhydroper-lateformat |
| version | 1.0.0 |
| created_at | 2025-02-19 13:03:00.454322+00 |
| updated_at | 2025-02-19 13:03:00.454322+00 |
| description | Late formatting of string parameters |
| homepage | |
| repository | https://github.com/realhydroper/rustlateformat |
| max_upload_size | |
| id | 1561299 |
| size | 20,362 |
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 realhydroper_lateformat::LateFormat;
use maplit::hashmap;
let user_string: String = "some user string: {id}".into();
assert_eq!(
"some user string: x",
user_string.realhydroper_lateformat(hashmap!{"id".into() => "x".into()})
);
let user_string: String = r#"some user string: {"id"}"#.into();
assert_eq!(
"some user string: id",
user_string.realhydroper_lateformat(hashmap!{"id".into() => "x".into()})
);
let user_string: String = r#"some user string: { "id" }"#.into();
assert_eq!(
"some user string: id",
user_string.realhydroper_lateformat(hashmap!{"id".into() => "x".into()})
);
let user_string: String = "some user string: {id}".into();
assert_eq!(
"some user string: None",
user_string.realhydroper_lateformat(hashmap!{})
);