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