Skip to content

Commit

Permalink
test: Improve tests for new get_mut() function
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Dec 9, 2024
1 parent b858503 commit 3545088
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
clippy:
Expand Down
7 changes: 4 additions & 3 deletions src/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ impl<K: Eq + Ord + Clone, V: Clone> Trie<K, V> {
/// let another_data = "notintest".bytes();
/// assert_eq!(t.get_mut(data.clone()), None);
/// t.insert(data.clone(), 42);
///
/// assert_eq!(t.get_mut(data), Some(42).as_mut());
/// assert_eq!(t.get(another_data), None);
/// if let Some(value) = t.get_mut(data.clone()) {
/// *value += 1;
/// }
/// assert_eq!(t.get_mut(data), Some(43).as_mut());
/// ```
pub fn get_mut<I: Iterator<Item = K>>(&mut self, key: I) -> Option<&mut V> {
self.find_node_mut(key).and_then(|node| node.get_value_mut())
Expand Down

0 comments on commit 3545088

Please sign in to comment.