Koka / gettext-rs

GNU Gettext FFI binding for Rust
51 stars 25 forks source link

Macros should "swallow" unsupported format specifiers #85

Closed Minoru closed 2 years ago

Minoru commented 2 years ago

gettext-rs provides a number of macros, of all which support {} for variable substitution, and some support {n} too. However, this support is coded such that unsupported stuff (e.g. {variable}, {:.3}, {:x}) passes through unchanged.

This is a problem because it makes introduction of new specifiers a breaking change. Users might already have strings with e.g. {:x}, and they rely on gettext-rs printing out {:x} in this case. We'd break that expectation if we added support for {:x}.

This is also inconsistent with how format! works: it always consumes anything that looks like a format specifier, and gives a compile-time error if the specifier is not supported (e.g. {:foobar}).

I suggest we mimic std's behaviour.

Minoru commented 2 years ago

This is now part of #86, so closing.