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:
+4
-1
@@ -15,9 +15,11 @@
|
|||||||
pub unsafe trait Array {
|
pub unsafe trait Array {
|
||||||
/// The array’s element type
|
/// The array’s element type
|
||||||
type Item;
|
type Item;
|
||||||
|
/// The smallest type that can index and tell the length of the array.
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// The smallest index type that indexes the array.
|
|
||||||
type Index: Index;
|
type Index: Index;
|
||||||
|
/// The array's element capacity
|
||||||
|
const CAPACITY: usize;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn as_ptr(&self) -> *const Self::Item;
|
fn as_ptr(&self) -> *const Self::Item;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
@@ -91,6 +93,7 @@ macro_rules! fix_array_impl {
|
|||||||
unsafe impl<T> Array for [T; $len] {
|
unsafe impl<T> Array for [T; $len] {
|
||||||
type Item = T;
|
type Item = T;
|
||||||
type Index = $index_type;
|
type Index = $index_type;
|
||||||
|
const CAPACITY: usize = $len;
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn as_ptr(&self) -> *const T { self as *const _ as *const _ }
|
fn as_ptr(&self) -> *const T { self as *const _ as *const _ }
|
||||||
|
|||||||
Reference in New Issue
Block a user