unfmt
: A compile-time pattern matching library that reverses the interpolation process of format!
.
unfmt
: A compile-time pattern matching library that reverses the interpolation process of format!
.
A compile-time pattern matching library that reverses the interpolation process of `format!`. - mathematic-inc/unfmt
How does it handle multiple potential outcomes? Example:
unformat!("a {} b {} c", "a x b b y c")
Would it returnSome(("x b", "y"))
orSome(("x", "b y"))
?12 0 ReplyI love the concept! I recently wanted something just like this for a Flutter app I was making to parse a filename into a user defined format i.e.
2024-04-12.txt
with%Y-%M-%D.txt
to{year: 2024, month: 04, day: 12}
I'll certainty be using this the next time I need anything like that in Rust though.
9 0 ReplyOff-topic, but I recognise your name. Thank you for the Daily Diary App! I'm a huge fan, I use it every day for my gratitude routine.
7 0 ReplyWow, I've never had anyone recognise my name for something I've made! Thank you so much and I'm glad you're enjoying it 😁
4 0 Reply
That's just brilliant.
7 0 ReplyThat’s really clever. I want to use it even though I haven’t been Rust‘ing lately
2 0 ReplyWhat am I missing? Seems like it just puts the parameter in
Some
?3 4 ReplyYou must've read that wrong.
The first example, but formatted differently:
let value = "My name is Rho."; let result = unformat!("My {} is {}.", value);
Now,
result
contains:Some(("name", "Rho"))
...because the words "name" and "Rho" in
value
happened to be at the position of the {}-slots in the unformat!()-pattern.21 0 ReplyOh yeah! Thanks. It's been a long day.
6 1 Reply