Skip to content

Commit

Permalink
Add method to remove values from settings maps (#787)
Browse files Browse the repository at this point in the history
This commit adds a method to remove values from settings maps.
  • Loading branch information
CryZe authored Mar 23, 2024
1 parent 591e760 commit a13ea1b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/livesplit-auto-splitting/src/settings/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ impl Map {
Arc::make_mut(&mut self.values).insert(key, value);
}

/// Removes a setting from the map and returns it if it exists. If the
/// setting doesn't exist, nothing happens.
#[inline]
pub fn remove(&mut self, key: &str) -> Option<Value> {
Arc::make_mut(&mut self.values).swap_remove(key)
}

/// Accesses the value of a setting by its key. While the setting may exist
/// as part of the user settings, it may not have been stored into the
/// settings map yet, so it may not exist, despite being registered.
Expand Down

0 comments on commit a13ea1b

Please sign in to comment.