[pdm-devel] [PATCH proxmox 2/3] section-config: remove DerefMut and make underlying HashMap private
Gabriel Goller
g.goller at proxmox.com
Wed Apr 23 11:44:29 CEST 2025
On 15.04.2025 10:42, Wolfgang Bumiller wrote:
>On Mon, Apr 14, 2025 at 02:00:44PM +0200, Gabriel Goller wrote:
>> [snip]
>> + /// Insert a key-value pair in the section config.
>> + ///
>> + /// If the key does not exist in the map, it will be added to the end of
>> + /// the order vector.
>> + ///
>> + /// # Returns
>> + ///
>> + /// * Some(value) - If the key was present, returns the previous value
>> + /// * None - If the key was not present
>> + pub fn insert(&mut self, key: String, value: T) -> Option<T> {
>
>Oh btw. this could be an `impl Into<String>` (or generic), that way we
>can at least avoid *some* double-clones...
>
Agree!
>> + let previous_value = self.sections.insert(key.clone(), value);
>> + // If there was no previous value, this is a new key, so add it to the order
>> + if previous_value.is_none() {
>> + self.order.push(key);
>> + }
>> + previous_value
>> + }
More information about the pdm-devel
mailing list