diff --git a/src/array_string.rs b/src/array_string.rs index a6410c2..2c5f422 100644 --- a/src/array_string.rs +++ b/src/array_string.rs @@ -152,6 +152,11 @@ impl> ArrayString { debug_assert!(length <= self.capacity()); self.len = Index::from(length); } + + /// Return a string slice of the whole `ArrayString`. + pub fn as_str(&self) -> &str { + self + } } impl> Deref for ArrayString { diff --git a/src/lib.rs b/src/lib.rs index 11c710a..3c9305f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -395,6 +395,16 @@ impl ArrayVec { self.clear(); 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 Deref for ArrayVec {