pub trait AsRaw {
type RawType;
fn as_raw(&self) -> *const Self::RawType;
}
pub trait AsRawMut: AsRaw {
fn as_raw_mut(&mut self) -> *mut Self::RawType {
unsafe { self.as_raw_mut_override() }
}
unsafe fn as_raw_mut_override(&self) -> *mut Self::RawType;
}
macro_rules! as_raw_impl {
($type_name:ty, $geos_type_name:ty) => {
impl AsRaw for $type_name {
type RawType = $geos_type_name;
fn as_raw(&self) -> *const Self::RawType {
self.ptr.as_ptr()
}
}
};
}
macro_rules! as_raw_mut_impl {
($type_name:ty, $geos_type_name:ty) => {
$crate::traits::as_raw_impl!($type_name, $geos_type_name);
impl AsRawMut for $type_name {
unsafe fn as_raw_mut_override(&self) -> *mut Self::RawType {
self.ptr.as_ptr()
}
}
};
}
pub(crate) use as_raw_impl;
pub(crate) use as_raw_mut_impl;