rust-lang/git2-rs

Add Revspec::into_objects

Opened this issue · 0 comments

It is currently not possible to extract the Objects from a Revspec without cloning, which is wasteful, since these are heap objects.

If this was a simple struct, you could just move out of the fields, but because it needs to be accessed through getter methods, this is not possible, and thus a separate method is needed.

impl<'repo> Revspec<'repo> {
  // RevparseMode is `Copy`, so it doesn't need to be returned in destructuring,
  // although maybe it should be for symmetry.
  fn into_objects(self) -> (Option<Object<'repo>>,  Option<Object<'repo>>);
}

This would be useful for when you want to collect all the commits into a Vec.