Skip to content

Commit 87217cc

Browse files
committed
fix!: change Graph::try_lookup_or_insert_default() to *::get_or_insert_default() and Graph::try_lookup_or_insert_commit() to *::get_or_insert_commit()
1 parent e44c372 commit 87217cc

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

gix-revwalk/src/graph/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ mod errors {
3030
}
3131

3232
///
33-
pub mod try_lookup_or_insert_default {
33+
pub mod get_or_insert_default {
3434
use crate::graph::commit::to_owned;
3535

3636
/// The error returned by [`try_lookup_or_insert_default()`](crate::Graph::try_lookup_or_insert_default()).
@@ -44,7 +44,7 @@ mod errors {
4444
}
4545
}
4646
}
47-
pub use errors::{insert_parents, try_lookup_or_insert_default};
47+
pub use errors::{get_or_insert_default, insert_parents};
4848
use gix_date::SecondsSinceUnixEpoch;
4949

5050
/// 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> {
6868
&mut self,
6969
id: gix_hash::ObjectId,
7070
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> {
7272
self.try_lookup_or_insert_default(id, T::default, update_data)
7373
}
7474
}
@@ -232,12 +232,12 @@ impl<'find, 'cache, T> Graph<'find, 'cache, Commit<T>> {
232232
/// `update_data(data)` gets run either on existing or on new data.
233233
///
234234
/// 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(
236236
&mut self,
237237
id: gix_hash::ObjectId,
238238
new_data: impl FnOnce() -> T,
239239
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> {
241241
match self.map.entry(id) {
242242
gix_hashtable::hash_map::Entry::Vacant(entry) => {
243243
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>> {
272272
///
273273
/// If only commit data is desired without the need for attaching custom data, use
274274
/// [`try_lookup(id).to_owned()`][Graph::try_lookup()] instead.
275-
pub fn try_lookup_or_insert_commit(
275+
pub fn get_or_insert_commit(
276276
&mut self,
277277
id: gix_hash::ObjectId,
278278
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)
281281
}
282282

283283
/// 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.
@@ -288,7 +288,7 @@ impl<'find, 'cache, T: Default> Graph<'find, 'cache, Commit<T>> {
288288
&mut self,
289289
id: gix_hash::ObjectId,
290290
update_commit: impl FnOnce(&mut Commit<T>),
291-
) -> Result<Option<&mut Commit<T>>, try_lookup_or_insert_default::Error> {
291+
) -> Result<Option<&mut Commit<T>>, get_or_insert_default::Error> {
292292
match self.map.entry(id) {
293293
gix_hashtable::hash_map::Entry::Vacant(entry) => {
294294
let res = try_lookup(&id, &*self.find, self.cache, &mut self.buf)?;
@@ -325,7 +325,7 @@ impl<'find, 'cache, T> Graph<'find, 'cache, T> {
325325
id: gix_hash::ObjectId,
326326
default: impl FnOnce() -> T,
327327
update_data: impl FnOnce(&mut T),
328-
) -> Result<Option<LazyCommit<'_, 'cache>>, try_lookup_or_insert_default::Error> {
328+
) -> Result<Option<LazyCommit<'_, 'cache>>, get_or_insert_default::Error> {
329329
let res = try_lookup(&id, &*self.find, self.cache, &mut self.buf)?;
330330
Ok(res.map(|commit| {
331331
match self.map.entry(id) {

0 commit comments

Comments
 (0)