Mercurial > hg
comparison rust/hg-core/src/dirstate_tree/dispatch.rs @ 47332:4ee9f419c52e
rust: Return owned instead of borrowed DirstateEntry in DirstateMap APIs
This will enable the tree-based DirstateMap to not always have an actual
DirstateEntry in memory for all nodes, but construct it on demand.
Differential Revision: https://phab.mercurial-scm.org/D10746
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 19 May 2021 13:15:00 +0200 |
parents | 1766130fe9ba |
children | ed1583a845d2 |
comparison
equal
deleted
inserted
replaced
47331:0252600fd1cf | 47332:4ee9f419c52e |
---|---|
115 | 115 |
116 fn len(&self) -> usize; | 116 fn len(&self) -> usize; |
117 | 117 |
118 fn contains_key(&self, key: &HgPath) -> bool; | 118 fn contains_key(&self, key: &HgPath) -> bool; |
119 | 119 |
120 fn get(&self, key: &HgPath) -> Option<&DirstateEntry>; | 120 fn get(&self, key: &HgPath) -> Option<DirstateEntry>; |
121 | 121 |
122 fn iter(&self) -> StateMapIter<'_>; | 122 fn iter(&self) -> StateMapIter<'_>; |
123 } | 123 } |
124 | 124 |
125 impl DirstateMapMethods for DirstateMap { | 125 impl DirstateMapMethods for DirstateMap { |
288 | 288 |
289 fn contains_key(&self, key: &HgPath) -> bool { | 289 fn contains_key(&self, key: &HgPath) -> bool { |
290 (&**self).contains_key(key) | 290 (&**self).contains_key(key) |
291 } | 291 } |
292 | 292 |
293 fn get(&self, key: &HgPath) -> Option<&DirstateEntry> { | 293 fn get(&self, key: &HgPath) -> Option<DirstateEntry> { |
294 (&**self).get(key) | 294 (&**self).get(key).cloned() |
295 } | 295 } |
296 | 296 |
297 fn iter(&self) -> StateMapIter<'_> { | 297 fn iter(&self) -> StateMapIter<'_> { |
298 Box::new((&**self).iter().map(|(key, value)| (&**key, value))) | 298 Box::new((&**self).iter().map(|(key, value)| (&**key, *value))) |
299 } | 299 } |
300 } | 300 } |