From ec87c5398df6e1a57c438c855e77c17382be02a9 Mon Sep 17 00:00:00 2001 From: Intege-rs Date: Mon, 30 Sep 2024 19:14:11 -0400 Subject: [PATCH] make x::null const --- proc_macro/Cargo.toml | 2 +- src/pointers.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/proc_macro/Cargo.toml b/proc_macro/Cargo.toml index e9aab38..9d66552 100644 --- a/proc_macro/Cargo.toml +++ b/proc_macro/Cargo.toml @@ -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"] } diff --git a/src/pointers.rs b/src/pointers.rs index d7e5289..ce32cdf 100644 --- a/src/pointers.rs +++ b/src/pointers.rs @@ -1,5 +1,5 @@ -pub fn null() -> T { T::new_null() } +pub const fn null() -> T { T::NULL } pub fn iterate(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 Pointer for *const T { type IterType = PIter; + const NULL: Self = core::ptr::null(); fn into_iter(self) -> Self::IterType { PIter(self) } - fn new_null() -> Self { core::ptr::null() } } impl Pointer for *mut T { type IterType = PIterMut; + const NULL: Self = core::ptr::null_mut(); fn into_iter(self) -> Self::IterType { PIterMut(self) } - fn new_null() -> Self { core::ptr::null_mut() } } } \ No newline at end of file