@@ -30,7 +30,7 @@ mod errors {
30
30
}
31
31
32
32
///
33
- pub mod try_lookup_or_insert_default {
33
+ pub mod get_or_insert_default {
34
34
use crate :: graph:: commit:: to_owned;
35
35
36
36
/// The error returned by [`try_lookup_or_insert_default()`](crate::Graph::try_lookup_or_insert_default()).
@@ -44,7 +44,7 @@ mod errors {
44
44
}
45
45
}
46
46
}
47
- pub use errors:: { insert_parents , try_lookup_or_insert_default } ;
47
+ pub use errors:: { get_or_insert_default , insert_parents } ;
48
48
use gix_date:: SecondsSinceUnixEpoch ;
49
49
50
50
/// The generation away from the HEAD of graph, useful to limit algorithms by topological depth as well.
@@ -68,7 +68,7 @@ impl<'find, 'cache, T: Default> Graph<'find, 'cache, T> {
68
68
& mut self ,
69
69
id : gix_hash:: ObjectId ,
70
70
update_data : impl FnOnce ( & mut T ) ,
71
- ) -> Result < Option < LazyCommit < ' _ , ' cache > > , try_lookup_or_insert_default :: Error > {
71
+ ) -> Result < Option < LazyCommit < ' _ , ' cache > > , get_or_insert_default :: Error > {
72
72
self . try_lookup_or_insert_default ( id, T :: default, update_data)
73
73
}
74
74
}
@@ -232,12 +232,12 @@ impl<'find, 'cache, T> Graph<'find, 'cache, Commit<T>> {
232
232
/// `update_data(data)` gets run either on existing or on new data.
233
233
///
234
234
/// Note that none of the data updates happen if `id` didn't exist.
235
- pub fn try_lookup_or_insert_commit_default (
235
+ pub fn get_or_insert_commit_default (
236
236
& mut self ,
237
237
id : gix_hash:: ObjectId ,
238
238
new_data : impl FnOnce ( ) -> T ,
239
239
update_data : impl FnOnce ( & mut T ) ,
240
- ) -> Result < Option < & mut Commit < T > > , try_lookup_or_insert_default :: Error > {
240
+ ) -> Result < Option < & mut Commit < T > > , get_or_insert_default :: Error > {
241
241
match self . map . entry ( id) {
242
242
gix_hashtable:: hash_map:: Entry :: Vacant ( entry) => {
243
243
let res = try_lookup ( & id, & * self . find , self . cache , & mut self . buf ) ?;
@@ -272,12 +272,12 @@ impl<'find, 'cache, T: Default> Graph<'find, 'cache, Commit<T>> {
272
272
///
273
273
/// If only commit data is desired without the need for attaching custom data, use
274
274
/// [`try_lookup(id).to_owned()`][Graph::try_lookup()] instead.
275
- pub fn try_lookup_or_insert_commit (
275
+ pub fn get_or_insert_commit (
276
276
& mut self ,
277
277
id : gix_hash:: ObjectId ,
278
278
update_data : impl FnOnce ( & mut T ) ,
279
- ) -> Result < Option < & mut Commit < T > > , try_lookup_or_insert_default :: Error > {
280
- self . try_lookup_or_insert_commit_default ( id, T :: default, update_data)
279
+ ) -> Result < Option < & mut Commit < T > > , get_or_insert_default :: Error > {
280
+ self . get_or_insert_commit_default ( id, T :: default, update_data)
281
281
}
282
282
283
283
/// Lookup `id` in the graph, but insert it if it's not yet present by looking it up without failing if the commit doesn't exist.
@@ -289,7 +289,7 @@ impl<'find, 'cache, T: Default> Graph<'find, 'cache, Commit<T>> {
289
289
& mut self ,
290
290
id : gix_hash:: ObjectId ,
291
291
update_commit : impl FnOnce ( & mut Commit < T > , bool ) ,
292
- ) -> Result < Option < & mut Commit < T > > , try_lookup_or_insert_default :: Error > {
292
+ ) -> Result < Option < & mut Commit < T > > , get_or_insert_default :: Error > {
293
293
match self . map . entry ( id) {
294
294
gix_hashtable:: hash_map:: Entry :: Vacant ( entry) => {
295
295
let res = try_lookup ( & id, & * self . find , self . cache , & mut self . buf ) ?;
@@ -326,7 +326,7 @@ impl<'find, 'cache, T> Graph<'find, 'cache, T> {
326
326
id : gix_hash:: ObjectId ,
327
327
default : impl FnOnce ( ) -> T ,
328
328
update_data : impl FnOnce ( & mut T ) ,
329
- ) -> Result < Option < LazyCommit < ' _ , ' cache > > , try_lookup_or_insert_default :: Error > {
329
+ ) -> Result < Option < LazyCommit < ' _ , ' cache > > , get_or_insert_default :: Error > {
330
330
let res = try_lookup ( & id, & * self . find , self . cache , & mut self . buf ) ?;
331
331
Ok ( res. map ( |commit| {
332
332
match self . map . entry ( id) {
0 commit comments