Skip to content

Commit 203dd18

Browse files
committed
add FixedSizeTable trait
1 parent 886c2f4 commit 203dd18

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/raw/array_table/table.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use core::{array, fmt, iter, mem, slice};
33
use super::{DrainIter, IterMut};
44

55
use crate::errors::{CapacityError, UnavailableMutError};
6-
use crate::raw::{RawTable, RawTableIter, TableIndex};
6+
use crate::raw::{FixedSizeTable, RawTable, RawTableIter, TableIndex};
77
use crate::utils::{self, unwrap_unchecked, ArrayExt, IterCircular};
88
use crate::{invariant, unreachable_unchecked};
99

@@ -248,6 +248,8 @@ impl<T, const N: usize> RawTable<T> for ArrayTable<T, N> {
248248
}
249249
}
250250

251+
impl<T, const N: usize> FixedSizeTable<T, N> for ArrayTable<T, N> {}
252+
251253
impl<'a, T, const N: usize> IntoIterator for &'a ArrayTable<T, N> {
252254
type IntoIter = iter::Flatten<slice::Iter<'a, Option<T>>>;
253255
type Item = &'a T;

src/raw/raw_table.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,6 @@ pub trait RawTableIter<T>: RawTable<T> {
153153
/// Returns an immutable iterator over the table.
154154
fn iter(&self) -> Self::Iter<'_>;
155155
}
156+
157+
/// A trait implemented by [`RawTable`]s with a fixed capacity.
158+
pub trait FixedSizeTable<T, const N: usize>: RawTable<T> {}

0 commit comments

Comments
 (0)