1 //! Bindings to libgit2's raw `git_oidarray` type
7 use crate::util
::Binding
;
11 /// An oid array structure used by libgit2
13 /// Some APIs return arrays of OIDs which originate from libgit2. This
14 /// wrapper type behaves a little like `Vec<&Oid>` but does so without copying
15 /// the underlying Oids until necessary.
17 raw
: raw
::git_oidarray
,
20 impl Deref
for OidArray
{
23 fn deref(&self) -> &[Oid
] {
25 debug_assert_eq
!(mem
::size_of
::<Oid
>(), mem
::size_of_val(&*self.raw
.ids
));
27 slice
::from_raw_parts(self.raw
.ids
as *const Oid
, self.raw
.count
as usize)
32 impl Binding
for OidArray
{
33 type Raw
= raw
::git_oidarray
;
34 unsafe fn from_raw(raw
: raw
::git_oidarray
) -> OidArray
{
37 fn raw(&self) -> raw
::git_oidarray
{
42 impl<'repo
> std
::fmt
::Debug
for OidArray
{
43 fn fmt(&self, f
: &mut std
::fmt
::Formatter
<'_
>) -> Result
<(), std
::fmt
::Error
> {
44 f
.debug_tuple("OidArray").field(&self.deref()).finish()
48 impl Drop
for OidArray
{
50 unsafe { raw::git_oidarray_free(&mut self.raw) }