mirror of
https://git.intege.rs/xlib/x.git
synced 2025-12-05 20:35:01 +00:00
make x::null const
This commit is contained in:
@@ -12,5 +12,5 @@ proc-macro = true
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
quote = "1"
|
quote = "1"
|
||||||
proc-macro2 = "1.0.66"
|
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 {
|
pub fn iterate<T: internal::Pointer>(pointer: T) -> T::IterType {
|
||||||
pointer.into_iter()
|
pointer.into_iter()
|
||||||
}
|
}
|
||||||
@@ -9,8 +9,8 @@ mod internal {
|
|||||||
|
|
||||||
pub trait Pointer {
|
pub trait Pointer {
|
||||||
type IterType;
|
type IterType;
|
||||||
|
const NULL: Self;
|
||||||
fn into_iter(self) -> Self::IterType;
|
fn into_iter(self) -> Self::IterType;
|
||||||
fn new_null() -> Self;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -40,14 +40,14 @@ mod internal {
|
|||||||
}
|
}
|
||||||
impl<T> Pointer for *const T {
|
impl<T> Pointer for *const T {
|
||||||
type IterType = PIter<T>;
|
type IterType = PIter<T>;
|
||||||
|
const NULL: Self = core::ptr::null();
|
||||||
fn into_iter(self) -> Self::IterType { PIter(self) }
|
fn into_iter(self) -> Self::IterType { PIter(self) }
|
||||||
fn new_null() -> Self { core::ptr::null() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Pointer for *mut T {
|
impl<T> Pointer for *mut T {
|
||||||
type IterType = PIterMut<T>;
|
type IterType = PIterMut<T>;
|
||||||
|
const NULL: Self = core::ptr::null_mut();
|
||||||
fn into_iter(self) -> Self::IterType { PIterMut(self) }
|
fn into_iter(self) -> Self::IterType { PIterMut(self) }
|
||||||
fn new_null() -> Self { core::ptr::null_mut() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user