Merge pull request #31 from bluss/as-slice
Add .as_slice(), .as_mut_slice(), .as_str()
This commit is contained in:
@@ -152,6 +152,11 @@ impl<A: Array<Item=u8>> ArrayString<A> {
|
|||||||
debug_assert!(length <= self.capacity());
|
debug_assert!(length <= self.capacity());
|
||||||
self.len = Index::from(length);
|
self.len = Index::from(length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return a string slice of the whole `ArrayString`.
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: Array<Item=u8>> Deref for ArrayString<A> {
|
impl<A: Array<Item=u8>> Deref for ArrayString<A> {
|
||||||
|
|||||||
+10
@@ -395,6 +395,16 @@ impl<A: Array> ArrayVec<A> {
|
|||||||
self.clear();
|
self.clear();
|
||||||
mem::forget(self);
|
mem::forget(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return a slice containing all elements of the vector.
|
||||||
|
pub fn as_slice(&self) -> &[A::Item] {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return a mutable slice containing all elements of the vector.
|
||||||
|
pub fn as_mut_slice(&mut self) -> &mut [A::Item] {
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: Array> Deref for ArrayVec<A> {
|
impl<A: Array> Deref for ArrayVec<A> {
|
||||||
|
|||||||
Reference in New Issue
Block a user