dtolnay / serde-yaml

Strongly typed YAML library for Rust
Apache License 2.0
965 stars 165 forks source link

Impl Mapping::entry_or_insert #197

Closed PsiACE closed 3 years ago

PsiACE commented 3 years ago

According to the actual use case of serde_yaml, impl fn entry_or_insert() for Mapping.

    /// Ensures a key's corresponding value is in the entry by inserting 
    /// the default if empty.
    /// Returns a mutable reference to the value in the entry.
    #[inline]
    pub fn entry_or_insert(&mut self, k: Value, default: Value) -> &mut Value {
        self.map.entry(k).or_insert(default)
    }

Relate https://github.com/dtolnay/serde-yaml/issues/58 . We don’t need to implement our own entry() API, but only need to combine the existing interfaces.

Also, I released my new crate ritelinked, which supports LinkedHashMap and LinkedHashSet, provides better performance in some cases and is under active maintenance, would you consider using it to replace linked-hash-map ?