History

Looks like the functional approach to locate(…) doesn't borrowcheck

Sebastian Thiel committed 6 years ago

Commit 5df68671 parent 9e68c6b1 file · +10 −2Browse files

Unified · Split

git-odb/src/compound.rs+10−2
@@ -32,8 +32,16 @@ mod locate { · 31 unmodified lines
3232 }
3333
3434 impl compound::Db {
35− pub fn locate<'a>(&self, _id: borrowed::Id, _buffer: &'a mut Vec<u8>) -> Option<Result<Object<'a>, Error>> {
36− unimplemented!("object location")
35+ pub fn locate<'a>(&self, id: borrowed::Id, buffer: &'a mut Vec<u8>) -> Option<Result<Object<'a>, Error>> {
36+ if let Some(object) = self
37+ .packs
38+ .iter()
39+ .find_map(|pack| pack.locate(id, buffer, &mut pack::cache::DecodeEntryNoop))
40+ {
41+ Some(object.map(|object| Object::Borrowed(object)).map_err(Into::into))
42+ } else {
43+ unimplemented!("object location")
44+ }
3745 }
3846 }
3947 }