Fmt library in Rust

Can someone recommend a stable crate that is close to fmt library in C++? I need to format some dynamic strings and I am looking for simplicity. I looked at handlebars, but I don't want to be constructing jsons data to fill out strings with a single placeholder.

How about the format! macro:
https://doc.rust-lang.org/std/macro.format.html

?

I need dynamic strings as a template

Did you search crates.io?

I did, but it's hard for me to determine, which crate is a reasonable choice. The top result was updated a year ago - not a great sign. Next one - 3 years ago, even worse. The next one was updated 5 months ago, but has only 126 downloads. None of these look like a good choice.

Compare to fmt library which had an activity yesterday. I don't need to guess whether it's a stable, reliable library.

If active maintenance is your first priority, check out dynfmt.

By the way, I don't think download count should be used as an indicator here. Dynamic string formatting is a pretty rare problem to solve in the Rust world – I would expect such libraries to have low download counts no matter how high quality they are.

1 Like

Note that not every crate needs updates. Download count is typically a good indicator. In this case, I'd try the strfmt crate first.

2 Likes

I'd recommend lib.rs when searching for packages. Their ranking algorithm yields better results, from my experience + it lists packages not present on crates.io.

1 Like