From 6c099e148f3b51e791159e1dc38c29712bf93181 Mon Sep 17 00:00:00 2001 From: bluss Date: Sat, 1 Dec 2018 11:58:01 +0100 Subject: [PATCH] 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. --- src/array.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/array.rs b/src/array.rs index 8d043e4..b6ccd01 100644 --- a/src/array.rs +++ b/src/array.rs @@ -15,9 +15,11 @@ pub unsafe trait Array { /// The array’s 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 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 _ }