4 ms·
Rust's format macro only takes string literals as a template, so you can't provide a runtime string template. The solution seems to be adding an external templa
by buckhx 10y ago
Rust's format macro only takes string literals as a template, so you can't provide a runtime string template. The solution seems to be adding an external templating lib, which seems like overkill for a single template.
- steveklabnik 10y agohttps://crates.io/crates/strfmt https://crates.io/crates/strfmt works too.
- chc 10y agoWouldn't that be an external templating lib?
- deleted 10y ago[deleted]
- steveklabnik 10y agoIn some sense, yes. In another, it's not some sort of different kind of templating, it's the same stuff, just calculated at runtime instead of compile time. I assume the lack of wanting a library for this is due to its weight and learning some other form of templating; this crate is pretty small, and isn't different in that way.
- Groxx 10y agoSeems like it could be replaced with just string concatenation? Slightly less pretty, perhaps, but that wouldn't require any dependencies.
- justinsaccount 10y agoWhy would you need to use a runtime string template? change new and base_url to accept an optional host parameter, if host is set return format!("{}://{}", match ssl..., host) otherwise run the existing codepath and return the amazonaws.com string.