Add as_{,mut_}ptr functions to ArrayVec, mirroring Vec

Fixes #135.
This commit is contained in:
Tobias Bucher
2019-10-05 21:01:58 +02:00
parent 8c3634ae9e
commit 516f1511f6
+10
View File
@@ -643,6 +643,16 @@ impl<A: Array> ArrayVec<A> {
pub fn as_mut_slice(&mut self) -> &mut [A::Item] { pub fn as_mut_slice(&mut self) -> &mut [A::Item] {
self self
} }
/// Return a raw pointer to the vector's buffer.
pub fn as_ptr(&self) -> *const A::Item {
self.xs.ptr()
}
/// Return a raw mutable pointer to the vector's buffer.
pub fn as_mut_ptr(&mut self) -> *mut A::Item {
self.xs.ptr_mut()
}
} }
impl<A: Array> Deref for ArrayVec<A> { impl<A: Array> Deref for ArrayVec<A> {