testeronious@lemmy.world to Rust@programming.dev · 8 months agounfmt: A compile-time pattern matching library that reverses the interpolation process of format!.github.comexternal-linkmessage-square9fedilinkarrow-up157arrow-down11
arrow-up156arrow-down1external-linkunfmt: A compile-time pattern matching library that reverses the interpolation process of format!.github.comtesteronious@lemmy.world to Rust@programming.dev · 8 months agomessage-square9fedilink
minus-squareonlinepersona@programming.devlinkfedilinkEnglisharrow-up3arrow-down4·8 months agoWhat am I missing? Seems like it just puts the parameter in Some? Anti Commercial-AI license
minus-squareEpheralinkfedilinkarrow-up20·edit-28 months agoYou 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.
minus-squareonlinepersona@programming.devlinkfedilinkEnglisharrow-up5arrow-down1·8 months agoOh yeah! Thanks. It’s been a long day. Anti Commercial-AI license
What am I missing? Seems like it just puts the parameter in
Some
?Anti Commercial-AI license
You 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.Oh yeah! Thanks. It’s been a long day.
Anti Commercial-AI license