From e36fb91b30e6c63e743ef188135349ca1db2598f Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 7 Nov 2021 14:57:40 +0100 Subject: [PATCH] Derive `Debug` for `IndexEntry`, `IndexTime`, and `Time` Sometimes it's useful to quickly dump an IndexEntry for debugging; having a `Debug` impl helps. Derive `Debug` for several time-related types (as well as the underlying structures in libgit2-sys). --- libgit2-sys/lib.rs | 4 ++-- src/index.rs | 1 + src/time.rs | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libgit2-sys/lib.rs b/libgit2-sys/lib.rs index 7f128cd0db..951397cc2c 100644 --- a/libgit2-sys/lib.rs +++ b/libgit2-sys/lib.rs @@ -143,7 +143,7 @@ pub struct git_signature { } #[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct git_time { pub time: git_time_t, pub offset: c_int, @@ -817,7 +817,7 @@ pub const GIT_INDEX_ENTRY_STAGEMASK: u16 = 0x3000; pub const GIT_INDEX_ENTRY_STAGESHIFT: u16 = 12; #[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct git_index_time { pub seconds: i32, pub nanoseconds: u32, diff --git a/src/index.rs b/src/index.rs index defc861eb8..22334d0c19 100644 --- a/src/index.rs +++ b/src/index.rs @@ -54,6 +54,7 @@ pub type IndexMatchedPath<'a> = dyn FnMut(&Path, &[u8]) -> i32 + 'a; /// All fields of an entry are public for modification and inspection. This is /// also how a new index entry is created. #[allow(missing_docs)] +#[derive(Debug)] pub struct IndexEntry { pub ctime: IndexTime, pub mtime: IndexTime, diff --git a/src/time.rs b/src/time.rs index 12a189e8b5..46b5bd3f94 100644 --- a/src/time.rs +++ b/src/time.rs @@ -6,13 +6,13 @@ use crate::raw; use crate::util::Binding; /// Time in a signature -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct Time { raw: raw::git_time, } /// Time structure used in a git index entry. -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct IndexTime { raw: raw::git_index_time, }