FIX: Add associated constant for Array's capacity

This isn't of much use at the moment, but future Rust features could
mean we can use it.
This commit is contained in:
bluss
2018-12-01 11:58:01 +01:00
parent 7496a5f597
commit 6c099e148f
+4 -1
View File
@@ -15,9 +15,11 @@
pub unsafe trait Array {
/// The arrays element type
type Item;
/// The smallest type that can index and tell the length of the array.
#[doc(hidden)]
/// The smallest index type that indexes the array.
type Index: Index;
/// The array's element capacity
const CAPACITY: usize;
#[doc(hidden)]
fn as_ptr(&self) -> *const Self::Item;
#[doc(hidden)]
@@ -91,6 +93,7 @@ macro_rules! fix_array_impl {
unsafe impl<T> Array for [T; $len] {
type Item = T;
type Index = $index_type;
const CAPACITY: usize = $len;
#[doc(hidden)]
#[inline(always)]
fn as_ptr(&self) -> *const T { self as *const _ as *const _ }