Added value method to get the generic type from TypedArenaPtr

This commit is contained in:
Fayeed Pawaskar
2023-09-04 14:11:30 +05:30
parent b105c33b79
commit 2c67106f26

View File

@@ -187,6 +187,12 @@ impl ArenaHeader {
#[derive(Debug)] #[derive(Debug)]
pub struct TypedArenaPtr<T: ?Sized>(ptr::NonNull<T>); pub struct TypedArenaPtr<T: ?Sized>(ptr::NonNull<T>);
impl TypedArenaPtr<Integer> {
pub fn value(&self) -> Integer {
unsafe { self.0.as_ref().clone() }
}
}
impl<T: ?Sized + PartialOrd> PartialOrd for TypedArenaPtr<T> { impl<T: ?Sized + PartialOrd> PartialOrd for TypedArenaPtr<T> {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
(**self).partial_cmp(&**other) (**self).partial_cmp(&**other)