Skip to content

Commit ab6213e

Browse files
committed
Remove sealed module
1 parent 3c97d2f commit ab6213e

9 files changed

Lines changed: 14 additions & 87 deletions

File tree

src/deque.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ impl<T, const N: usize> Deque<T, N> {
152152
/// static mut X: Deque<u8, 16> = Deque::new();
153153
/// ```
154154
pub const fn new() -> Self {
155-
// Const assert N > 0
156-
crate::sealed::greater_than_0::<N>();
155+
assert!(N > 0);
157156

158157
Self {
159158
phantom: PhantomData,

src/histbuf.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ impl<T, const N: usize> HistoryBuffer<T, N> {
208208
/// ```
209209
#[inline]
210210
pub const fn new() -> Self {
211-
// Const assert
212-
crate::sealed::greater_than_0::<N>();
211+
assert!(N > 0);
213212

214213
Self {
215214
phantom: PhantomData,

src/indexmap.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,7 @@ pub struct IndexMap<K, V, S, const N: usize> {
729729
impl<K, V, S, const N: usize> IndexMap<K, V, BuildHasherDefault<S>, N> {
730730
/// Creates an empty `IndexMap`.
731731
pub const fn new() -> Self {
732-
// Const assert
733-
crate::sealed::greater_than_1::<N>();
734-
crate::sealed::power_of_two::<N>();
732+
assert!(N > 1 && N.is_power_of_two());
735733

736734
IndexMap {
737735
build_hasher: BuildHasherDefault::new(),
@@ -1237,8 +1235,12 @@ where
12371235
{
12381236
fn default() -> Self {
12391237
// Const assert
1240-
crate::sealed::greater_than_1::<N>();
1241-
crate::sealed::power_of_two::<N>();
1238+
{
1239+
assert!(N > 1);
1240+
};
1241+
{
1242+
assert!(N > 0 && N.is_power_of_two());
1243+
};
12421244

12431245
IndexMap {
12441246
build_hasher: <_>::default(),

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ pub mod spsc;
215215
#[cfg(feature = "ufmt")]
216216
mod ufmt;
217217

218-
mod sealed;
219-
220218
/// Implementation details for macros.
221219
/// Do not use. Used for macros only. Not covered by semver guarantees.
222220
#[doc(hidden)]

src/mpmc.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,10 @@ pub type MpMcQueue<T, const N: usize> = MpMcQueueInner<T, OwnedStorage<N>>;
151151
pub type MpMcQueueView<T> = MpMcQueueInner<T, ViewStorage>;
152152

153153
impl<T, const N: usize> MpMcQueue<T, N> {
154-
const ASSERT: [(); 1] = [()];
155-
156154
/// Creates an empty queue
157155
pub const fn new() -> Self {
158-
// Const assert
159-
crate::sealed::greater_than_1::<N>();
160-
crate::sealed::power_of_two::<N>();
161-
162-
// Const assert on size.
163-
#[allow(clippy::no_effect)]
164-
Self::ASSERT[(N >= (UintSize::MAX as usize)) as usize];
156+
assert!(N > 1 && N.is_power_of_two());
157+
assert!(N < UintSize::MAX as usize);
165158

166159
let mut cell_count = 0;
167160

src/sealed.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

src/sorted_linked_list.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ macro_rules! impl_index_and_const_new {
237237

238238
/// Create a new linked list.
239239
pub const fn $new_name() -> Self {
240-
// Const assert N < MAX
241-
crate::sealed::smaller_than::<N, $max_val>();
240+
assert!(N < $max_val);
242241

243242
let mut list = SortedLinkedList {
244243
list: OwnedSortedLinkedListStorage {

src/spsc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ pub type QueueView<T> = QueueInner<T, ViewStorage>;
143143
impl<T, const N: usize> Queue<T, N> {
144144
/// Creates an empty queue with a fixed capacity of `N - 1`
145145
pub const fn new() -> Self {
146-
// Const assert N > 1
147-
crate::sealed::greater_than_1::<N>();
146+
assert!(N > 1);
148147

149148
Queue {
150149
head: AtomicUsize::new(0),

src/vec/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,7 @@ impl<T, const N: usize> Vec<T, N> {
211211
/// If the length of the provided array is greater than the capacity of the
212212
/// vector a compile-time error will be produced.
213213
pub fn from_array<const M: usize>(src: [T; M]) -> Self {
214-
// Const assert M >= 0
215-
crate::sealed::greater_than_eq_0::<M>();
216-
// Const assert N >= M
217-
crate::sealed::greater_than_eq::<N, M>();
214+
assert!(N >= M);
218215

219216
// We've got to copy `src`, but we're functionally moving it. Don't run
220217
// any Drop code for T.

0 commit comments

Comments
 (0)