Skip to content

Compatibility hazard with Key #291

@Kixunil

Description

@Kixunil

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatibilityCategory: Changes that affect compatibilityP-highPriority: High

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions