make x::null const
This commit is contained in:
@@ -12,5 +12,5 @@ proc-macro = true
|
||||
[dependencies]
|
||||
quote = "1"
|
||||
proc-macro2 = "1.0.66"
|
||||
syn = { version = "2.0.66", features = ["full"] }
|
||||
syn = { version = "2.0.48", features = ["full"] }
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
pub fn null<T: internal::Pointer>() -> T { T::new_null() }
|
||||
pub const fn null<T: internal::Pointer>() -> T { T::NULL }
|
||||
pub fn iterate<T: internal::Pointer>(pointer: T) -> T::IterType {
|
||||
pointer.into_iter()
|
||||
}
|
||||
@@ -9,8 +9,8 @@ mod internal {
|
||||
|
||||
pub trait Pointer {
|
||||
type IterType;
|
||||
const NULL: Self;
|
||||
fn into_iter(self) -> Self::IterType;
|
||||
fn new_null() -> Self;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,14 +40,14 @@ mod internal {
|
||||
}
|
||||
impl<T> Pointer for *const T {
|
||||
type IterType = PIter<T>;
|
||||
const NULL: Self = core::ptr::null();
|
||||
fn into_iter(self) -> Self::IterType { PIter(self) }
|
||||
fn new_null() -> Self { core::ptr::null() }
|
||||
}
|
||||
|
||||
impl<T> Pointer for *mut T {
|
||||
type IterType = PIterMut<T>;
|
||||
const NULL: Self = core::ptr::null_mut();
|
||||
fn into_iter(self) -> Self::IterType { PIterMut(self) }
|
||||
fn new_null() -> Self { core::ptr::null_mut() }
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user