Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit a5f9cb2

Browse files
authored
Merge pull request #579 from luukvanderduim/master
Implements FromGlibPtrFull<*const T> for boxed types.
2 parents e8a28ad + 07660e2 commit a5f9cb2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/boxed.rs

+20
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ macro_rules! glib_boxed_wrapper {
169169
}
170170
}
171171

172+
#[doc(hidden)]
173+
impl $crate::translate::FromGlibPtrFull<*const $ffi_name> for $name {
174+
#[inline]
175+
#[allow(clippy::missing_safety_doc)]
176+
unsafe fn from_glib_full(ptr: *const $ffi_name) -> Self {
177+
$name($crate::translate::from_glib_full(ptr))
178+
}
179+
}
180+
172181
#[doc(hidden)]
173182
impl $crate::translate::FromGlibPtrBorrow<*mut $ffi_name> for $name {
174183
#[inline]
@@ -457,6 +466,17 @@ impl<T: 'static, MM: BoxedMemoryManager<T>> FromGlibPtrFull<*mut T> for Boxed<T,
457466
}
458467
}
459468

469+
impl<T: 'static, MM: BoxedMemoryManager<T>> FromGlibPtrFull<*const T> for Boxed<T, MM> {
470+
#[inline]
471+
unsafe fn from_glib_full(ptr: *const T) -> Self {
472+
assert!(!ptr.is_null());
473+
Boxed {
474+
inner: AnyBox::ForeignOwned(ptr::NonNull::new_unchecked(ptr as *mut T)),
475+
_dummy: PhantomData,
476+
}
477+
}
478+
}
479+
460480
impl<T: 'static, MM: BoxedMemoryManager<T>> FromGlibPtrBorrow<*mut T> for Boxed<T, MM> {
461481
#[inline]
462482
unsafe fn from_glib_borrow(ptr: *mut T) -> Self {

0 commit comments

Comments
 (0)