Method implementations for fixed size arrays
Working with slices is often more convenient than working with arrays. See also slice for methods on slices.
Methods
impl array<Arr> { ... }
Arr: Array
-
fn as_slice(self: &Arr) -> &[element_of<Arr>]
-
fn as_slice_mut(self: &mut Arr) -> &mut [element_of<Arr>]
-
fn as_ptr(self: &Arr) -> &element_of<Arr>
Returns a pointer to the first element.
-
fn as_ptr_mut(self: &mut Arr) -> &mut element_of<Arr>
Returns a mutable pointer to the first element.
-
fn len(self: &Arr) -> usize
Returns the number of elements in the array.
Prefer to use this function instead of size_of, as it can lead to surprising results when array's element is a zero-sized type.
Example
let a: [u32; 8]; let b: [u32; 0]; let c: [(); 10]; // zero-sized assert_eq!(a.len(), 8); assert_eq!(b.len(), 0); assert_eq!(c.len(), 10);
Run this example -
fn iter(self: &Arr) -> SliceIterator<&element_of<Arr>>
-
fn equals(lhs: &Arr, rhs: &Arr) -> bool
-
fn hash<H>(lhs: &Arr, h: &mut H)
H: Hasher<H>
Mixins
impl array<Arr> { ... }
Arr: Array
-
mixin Equatable<Arr>
-
Returns
false
if arguments are equal,true
otherwise