Skip to content

Commit

Permalink
re-add UnwrapMutOrNull for linux
Browse files Browse the repository at this point in the history
Signed-off-by: Walker Crouse <[email protected]>
  • Loading branch information
windy1 committed Jul 26, 2024
1 parent 70c3d8f commit fd3dc5d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions zeroconf/src/ffi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ impl<T> UnwrapOrNull<T> for Option<*const T> {
}
}

/// Helper trait to unwrap a type to a `*mut T` or a null-pointer if not present.
#[cfg(target_os = "linux")]
pub trait UnwrapMutOrNull<T> {
/// Unwraps this type to `*mut T` or `ptr::null_mut()` if not present.
fn unwrap_mut_or_null(&mut self) -> *mut T;
}

#[cfg(target_os = "linux")]
impl<T> UnwrapMutOrNull<T> for Option<*mut T> {
fn unwrap_mut_or_null(&mut self) -> *mut T {
self.unwrap_or_else(ptr::null_mut)
}
}

#[cfg(target_vendor = "apple")]
pub(crate) mod bonjour {
use crate::Result;
Expand Down

0 comments on commit fd3dc5d

Please sign in to comment.