late_format

Crates.iolate_format
lib.rslate_format
version1.0.0
sourcesrc
created_at2023-10-23 12:31:32.781201
updated_at2023-10-23 12:31:32.781201
descriptionLate formatting of string parameters
homepage
repositoryhttps://github.com/hydroper/rust_late_format
max_upload_size
id1011284
size5,277
Matheus Dias de Souza (hydroper)

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 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!{})
);
Commit count: 4

cargo fmt