1#[doc(inline)]
10pub use self::point::BasePoint;
11
12pub(crate) mod point;
13
14pub(crate) mod prelude {
15 pub use super::point::*;
16 pub use super::RawPoint;
17}
18
19pub trait RawPoint {
21 type Elem;
22
23 fn as_ptr(&self) -> *const Self::Elem;
24
25 fn as_mut_ptr(&mut self) -> *mut Self::Elem;
26
27 fn as_slice(&self) -> &[Self::Elem];
28
29 fn as_mut_slice(&mut self) -> &mut [Self::Elem];
30
31 fn len(&self) -> usize;
32
33 fn is_empty(&self) -> bool {
34 self.len() == 0
35 }
36}
37
38#[cfg(feature = "alloc")]
42use alloc::vec::Vec;
43
44impl<A> RawPoint for [A] {
45 type Elem = A;
46
47 fn as_ptr(&self) -> *const Self::Elem {
48 self.as_ptr()
49 }
50
51 fn as_mut_ptr(&mut self) -> *mut Self::Elem {
52 self.as_mut_ptr()
53 }
54
55 fn as_slice(&self) -> &[Self::Elem] {
56 &self
57 }
58
59 fn as_mut_slice(&mut self) -> &mut [Self::Elem] {
60 self
61 }
62
63 fn len(&self) -> usize {
64 self.len()
65 }
66}
67
68#[cfg(feature = "alloc")]
69impl<T> RawPoint for Vec<T> {
70 type Elem = T;
71
72 fn as_ptr(&self) -> *const Self::Elem {
73 Vec::as_ptr(self)
74 }
75
76 fn as_mut_ptr(&mut self) -> *mut Self::Elem {
77 Vec::as_mut_ptr(self)
78 }
79
80 fn as_slice(&self) -> &[Self::Elem] {
81 Vec::as_slice(self)
82 }
83
84 fn as_mut_slice(&mut self) -> &mut [Self::Elem] {
85 Vec::as_mut_slice(self)
86 }
87
88 fn len(&self) -> usize {
89 Vec::len(self)
90 }
91
92 fn is_empty(&self) -> bool {
93 Vec::is_empty(self)
94 }
95}
96
97impl<S> RawPoint for BasePoint<S>
98where
99 S: RawPoint,
100{
101 type Elem = S::Elem;
102
103 fn as_ptr(&self) -> *const Self::Elem {
104 self.data.as_ptr()
105 }
106
107 fn as_mut_ptr(&mut self) -> *mut Self::Elem {
108 self.data.as_mut_ptr()
109 }
110
111 fn as_slice(&self) -> &[Self::Elem] {
112 self.data.as_slice()
113 }
114
115 fn as_mut_slice(&mut self) -> &mut [Self::Elem] {
116 self.data.as_mut_slice()
117 }
118
119 fn len(&self) -> usize {
120 self.data.len()
121 }
122}
123