diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-01-23 13:24:39 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-01-23 13:26:10 +0100 |
| commit | 2b8426b1b3a19d46a94abaece674525948c146af (patch) | |
| tree | 35eae5b09cda399224c58543f58a985cfcd00e79 /src/model/dict.rs | |
| parent | 6ca240508eed7288fcc317b9e167f6470a2f952c (diff) | |
Interpret methods on modules as functions in modules
Diffstat (limited to 'src/model/dict.rs')
| -rw-r--r-- | src/model/dict.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/model/dict.rs b/src/model/dict.rs index a5dbeeae..e94db923 100644 --- a/src/model/dict.rs +++ b/src/model/dict.rs @@ -54,11 +54,10 @@ impl Dict { } /// Mutably borrow the value the given `key` maps to. - /// - /// This inserts the key with [`None`](Value::None) as the value if not - /// present so far. - pub fn at_mut(&mut self, key: Str) -> &mut Value { - Arc::make_mut(&mut self.0).entry(key).or_default() + pub fn at_mut(&mut self, key: &str) -> StrResult<&mut Value> { + Arc::make_mut(&mut self.0) + .get_mut(key) + .ok_or_else(|| missing_key(key)) } /// Remove the value if the dictionary contains the given key. |
