We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5573e52 commit ab1ac88Copy full SHA for ab1ac88
src/cxx_vector.rs
@@ -125,6 +125,21 @@ where
125
}
126
127
128
+ /// Returns a slice to the underlying contiguous array of elements by
129
+ /// mutable reference.
130
+ pub fn as_mut_slice(self: Pin<&mut Self>) -> &mut [T]
131
+ where
132
+ T: ExternType<Kind = Trivial>,
133
+ {
134
+ let len = self.len();
135
+ if len == 0 {
136
+ &mut []
137
+ } else {
138
+ let ptr = unsafe { T::__get_unchecked(self.get_unchecked_mut(), 0) };
139
+ unsafe { slice::from_raw_parts_mut(ptr, len) }
140
+ }
141
142
+
143
/// Returns an iterator over elements of type `&T`.
144
pub fn iter(&self) -> Iter<T> {
145
Iter { v: self, index: 0 }
0 commit comments