hydroperx-lateformat

Crates.iohydroperx-lateformat
lib.rshydroperx-lateformat
version1.0.1
created_at2025-05-17 14:27:08.987735+00
updated_at2025-07-05 19:37:34.175417+00
descriptionLate formatting of string parameters
homepage
repositoryhttps://github.com/hydroperx/lateformat.rs
max_upload_size
id1677923
size20,162
Matheus Dias de Souza (hydroperx)

documentation

README

Late format

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.

Example

use hydroperx_lateformat::LateFormat;
use maplit::hashmap;

let user_string: String = "some user string: {id}".into();
assert_eq!(
    "some user string: x",
    user_string.lateformat(hashmap!{"id".into() => "x".into()})
);

let user_string: String = r#"some user string: {"id"}"#.into();
assert_eq!(
    "some user string: id",
    user_string.lateformat(hashmap!{"id".into() => "x".into()})
);

let user_string: String = r#"some user string: {  "id"  }"#.into();
assert_eq!(
    "some user string: id",
    user_string.lateformat(hashmap!{"id".into() => "x".into()})
);

let user_string: String = "some user string: {id}".into();
assert_eq!(
    "some user string: None",
    user_string.lateformat(hashmap!{})
);
Commit count: 3

cargo fmt