I noticed that Key is a type alias or a newtype depending on used features. This is a compatibility hazard.
For example:
Crate A:
serializer.emit_arguments("foo", &format_args!("bar"))
Crate B:
With featrue dynamic_keys
serializer.emit_arguments(Key::from(compute_key_string()), &format_args!("baz"))
Crate C depends on both A and B -> crate A will break.
One can defend against this by always using Key::from, but it's possible to forget and clippy complains about useless conversion.
I think the best course of action is to use a newtype for static keys too. It will be breaking for crates that don't defend but it's probably more predictable and easier to handle than the situation above.
I noticed that
Keyis a type alias or a newtype depending on used features. This is a compatibility hazard.For example:
Crate A:
Crate B:
With featrue
dynamic_keysCrate C depends on both A and B -> crate A will break.
One can defend against this by always using
Key::from, but it's possible to forget and clippy complains about useless conversion.I think the best course of action is to use a newtype for static keys too. It will be breaking for crates that don't defend but it's probably more predictable and easier to handle than the situation above.