Add [T; N]::as_[mut_]slice
These methods are like the ones on `std::array::FixedSizeArray` and in the crate `arraytools`.
This commit is contained in:
parent
85fbf49ce0
commit
104a02301c
@ -422,4 +422,17 @@ fn drop(&mut self) {
|
|||||||
// and we just need to cast it to the correct type.
|
// and we just need to cast it to the correct type.
|
||||||
unsafe { crate::mem::transmute_copy::<_, [U; N]>(&dst) }
|
unsafe { crate::mem::transmute_copy::<_, [U; N]>(&dst) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a slice containing the entire array. Equivalent to `&s[..]`.
|
||||||
|
#[unstable(feature = "array_methods", issue = "76118")]
|
||||||
|
pub fn as_slice(&self) -> &[T] {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a mutable slice containing the entire array. Equivalent to
|
||||||
|
/// `&mut s[..]`.
|
||||||
|
#[unstable(feature = "array_methods", issue = "76118")]
|
||||||
|
pub fn as_mut_slice(&mut self) -> &mut [T] {
|
||||||
|
self
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user