Skip to content

Commit c321bf2

Browse files
committed
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.
1 parent 97eb3fd commit c321bf2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/array.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
pub unsafe trait Array {
1616
/// The array’s element type
1717
type Item;
18+
/// The smallest type that can index and tell the length of the array.
1819
#[doc(hidden)]
19-
/// The smallest index type that indexes the array.
2020
type Index: Index;
21+
/// The array's element capacity
22+
const CAPACITY: usize;
2123
#[doc(hidden)]
2224
fn as_ptr(&self) -> *const Self::Item;
2325
#[doc(hidden)]
@@ -91,6 +93,7 @@ macro_rules! fix_array_impl {
9193
unsafe impl<T> Array for [T; $len] {
9294
type Item = T;
9395
type Index = $index_type;
96+
const CAPACITY: usize = $len;
9497
#[doc(hidden)]
9598
#[inline(always)]
9699
fn as_ptr(&self) -> *const T { self as *const _ as *const _ }

0 commit comments

Comments
 (0)