Skip to content

Commit

Permalink
Update for latest git changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Morganamilo committed Sep 12, 2023
1 parent 643ff21 commit 60c4b42
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions alpm/src/conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,19 @@ pub struct Conflict<'a> {

impl<'a> fmt::Debug for Conflict<'a> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Conflict")
.field("package1", &self.package1())
.field("package1_hash", &self.package1_hash())
.field("package2", &self.package2())
.field("package2_hash", &self.package2_hash())
.field("reason", &self.reason())
.finish()
#[cfg(not(feature = "git"))]
{
f.debug_struct("Conflict")
.field("package1", &self.package1())
.field("package2", &self.package2())
.field("reason", &self.reason())
.finish()
}
// Implement properly when we merge the no handle code
#[cfg(feature = "git")]
{
f.debug_struct("Conflict").finish()
}
}
}

Expand Down Expand Up @@ -70,28 +76,42 @@ impl<'a> Conflict<'a> {
self.inner.as_ptr()
}

#[cfg(not(feature = "git"))]
pub fn package1_hash(&self) -> u64 {
#[allow(clippy::useless_conversion)]
unsafe {
(*self.as_ptr()).package1_hash.into()
}
}

#[cfg(not(feature = "git"))]
pub fn package2_hash(&self) -> u64 {
#[allow(clippy::useless_conversion)]
unsafe {
(*self.as_ptr()).package2_hash.into()
}
}

#[cfg(not(feature = "git"))]
pub fn package1(&self) -> &'a str {
unsafe { from_cstr((*self.as_ptr()).package1) }
}

#[cfg(not(feature = "git"))]
pub fn package2(&self) -> &'a str {
unsafe { from_cstr((*self.as_ptr()).package2) }
}

#[cfg(feature = "git")]
pub fn package1(&self) -> &'a str {
unsafe { from_cstr(alpm_pkg_get_name((*self.as_ptr()).package1)) }
}

#[cfg(feature = "git")]
pub fn package2(&self) -> &'a str {
unsafe { from_cstr(alpm_pkg_get_name((*self.as_ptr()).package2)) }
}

pub fn reason(&self) -> Dep<'a> {
unsafe { Dep::from_ptr((*self.as_ptr()).reason) }
}
Expand Down

0 comments on commit 60c4b42

Please sign in to comment.