playdate_sys/
traits.rs

1//! Helpful traits for API parts unification.
2
3
4pub trait AsRaw {
5	type Type;
6	/// This method ia actually safe.
7	/// Unsafety is because so we're removing owners lifetime that used by some API parts.
8	unsafe fn as_raw(&self) -> *mut Self::Type;
9}
10
11impl<T: AsRaw<Type = Ptr>, Ptr> AsRaw for &'_ T {
12	type Type = Ptr;
13	#[inline(always)]
14	unsafe fn as_raw(&self) -> *mut Ptr { (*self).as_raw() }
15}
16
17impl<T> AsRaw for *mut T {
18	type Type = T;
19	#[inline(always)]
20	unsafe fn as_raw(&self) -> *mut T { *self }
21}