use std::boxed::Box;
use core::option::Option;
use core::cmp::PartialEq;
use core::ptr::NonNull;
use core::fmt;
pub struct Node<T> {
pub next: Option<NonNull<Node<T>>>,
pub value: T,
}
impl<T> Node<T> {
#[inline]
pub const fn new(value: T) -> Self {
return Self {
next: None,
value,
};
}
#[inline]
pub fn into_box(self) -> Box<Self> {
return Box::new(self);
}
}
impl<T: PartialEq> PartialEq for Node<T> {
fn eq(&self, other: &Self) -> bool {
return self.value == other.value;
}
}
impl<T: fmt::Debug> fmt::Debug for Node<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
return f.debug_struct("Node")
.field("next", &self.next)
.field("value", &self.value)
.finish();
}
}