Skip to content

Commit cd2e8fd

Browse files
committed
libgit2-rs: Update for 2nd edition.
1 parent 20283f8 commit cd2e8fd

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

libgit2-rs/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
name = "libgit2-rs"
33
version = "0.1.0"
44
authors = ["You <[email protected]>"]
5-
build = "build.rs"
5+
edition = "2018"
66

77
[dependencies]

libgit2-rs/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
fn main() {
2-
println!("cargo:rustc-link-search=native=/home/jimb/libgit2-0.25.1/build");
2+
println!(r"cargo:rustc-link-search=native=/home/jimb/libgit2-0.25.1/build");
33
}

libgit2-rs/src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![warn(rust_2018_idioms)]
2+
#![allow(elided_lifetimes_in_paths)]
3+
14
mod raw;
25

36
use std::ffi::CStr;
@@ -48,9 +51,12 @@ fn main() {
4851
raw::git_repository_open(&mut repo, path.as_ptr()));
4952

5053
let c_name = b"HEAD\0".as_ptr() as *const c_char;
51-
let mut oid = mem::uninitialized();
52-
check("looking up HEAD",
53-
raw::git_reference_name_to_id(&mut oid, repo, c_name));
54+
let oid = {
55+
let mut oid = mem::MaybeUninit::uninit();
56+
check("looking up HEAD",
57+
raw::git_reference_name_to_id(oid.as_mut_ptr(), repo, c_name));
58+
oid.assume_init()
59+
};
5460

5561
let mut commit = ptr::null_mut();
5662
check("looking up commit",

libgit2-rs/src/raw.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,20 @@ extern {
2525
pub fn git_commit_free(commit: *mut git_commit);
2626
}
2727

28-
pub enum git_repository {}
29-
pub enum git_commit {}
28+
#[repr(C)] pub struct git_repository { _private: [u8; 0] }
29+
#[repr(C)] pub struct git_commit { _private: [u8; 0] }
3030

3131
#[repr(C)]
3232
pub struct git_error {
3333
pub message: *const c_char,
3434
pub klass: c_int
3535
}
3636

37+
pub const GIT_OID_RAWSZ: usize = 20;
38+
3739
#[repr(C)]
3840
pub struct git_oid {
39-
pub id: [c_uchar; 20]
41+
pub id: [c_uchar; GIT_OID_RAWSZ]
4042
}
4143

4244
pub type git_time_t = i64;

0 commit comments

Comments
 (0)