Skip to content

Use try_insert for Dictionary Decoding when Stabilized #781

@InsertCreativityHere

Description

@InsertCreativityHere

(See stabilization tracking thread for feature(map_try_insert) here)

HashMap::insert and BTreeMap::insert take a key,value by value.
Meaning that once insert is called, we can no longer access the key.
This prevents us from including the offending key in the message of a DuplidateDictionaryKey error.
Note that insert will return you the old value (in the case of a duplicate), but not the old key.

However, there is a new try_insert function on nightly rust which unlike insert (which will always replace an existing entry), try_insert will fail with an Err if the key is already present. And the returned Err includes both the key and value.

When this function is stabilized, we should update our dictionary decoding to take advantage of it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Waiting on upstreamThis Issue is on hold, waiting on some upstream dependencyeasyGood for newcomersslice-codecRelated to the 'slice-codec' crate
    No fields configured for Enhancement.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions