libutils_pointer/
conversions.rs1use super::Pointer;
7
8use core::ptr::NonNull;
10
11
12const impl<Type> From<NonNull<Type>> for Pointer<Type> {
18 fn from(value: NonNull<Type>) -> Self {return Self {
19 to: Some(value)
20 }}
21}
22
23const impl<Type> From<Option<NonNull<Type>>> for Pointer<Type> {
25 fn from(value: Option<NonNull<Type>>) -> Self {return Self {
26 to: value
27 }}
28}
29
30const impl<Type> From<*mut Type> for Pointer<Type> {
32 fn from(value: *mut Type) -> Self {return Self {
33 to: NonNull::new(value)
34 }}
35}
36
37const impl<Type> From<&mut Type> for Pointer<Type> {
39 fn from(value: &mut Type) -> Self {Self::from(value as *mut Type)}
40}