Skip to content

Commit

Permalink
feat: Provide mutable access to keys within entries
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Apr 26, 2022
1 parent 23275eb commit 4156603
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/inline_table.rs
Expand Up @@ -509,6 +509,11 @@ impl<'a> InlineOccupiedEntry<'a> {
self.entry.key().as_str()
}

/// Gets a mutable reference to the entry key
pub fn key_mut(&mut self) -> KeyMut<'_> {
self.entry.get_mut().key.as_mut()
}

/// Gets a reference to the value in the entry.
pub fn get(&self) -> &Value {
self.entry.get().value.as_value().unwrap()
Expand Down
5 changes: 5 additions & 0 deletions src/table.rs
Expand Up @@ -621,6 +621,11 @@ impl<'a> OccupiedEntry<'a> {
self.entry.key().as_str()
}

/// Gets a mutable reference to the entry key
pub fn key_mut(&mut self) -> KeyMut<'_> {
self.entry.get_mut().key.as_mut()
}

/// Gets a reference to the value in the entry.
pub fn get(&self) -> &Item {
&self.entry.get().value
Expand Down

0 comments on commit 4156603

Please sign in to comment.