Skip to content

Commit 18446d7

Browse files
committed
Remove sealed module
1 parent bfc9598 commit 18446d7

File tree

9 files changed

+28
-88
lines changed

9 files changed

+28
-88
lines changed

src/deque.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ 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+
const {
156+
assert!(N > 0);
157+
}
157158

158159
Self {
159160
phantom: PhantomData,

src/histbuf.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ 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+
const {
212+
assert!(N > 0);
213+
}
213214

214215
Self {
215216
phantom: PhantomData,

src/indexmap.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,10 @@ 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+
const {
733+
assert!(N > 1);
734+
assert!(N.is_power_of_two());
735+
}
735736

736737
Self {
737738
build_hasher: BuildHasherDefault::new(),
@@ -1236,9 +1237,10 @@ where
12361237
S: Default,
12371238
{
12381239
fn default() -> Self {
1239-
// Const assert
1240-
crate::sealed::greater_than_1::<N>();
1241-
crate::sealed::power_of_two::<N>();
1240+
const {
1241+
assert!(N > 1);
1242+
assert!(N.is_power_of_two());
1243+
}
12421244

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

src/lib.rs

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

224-
mod sealed;
225-
226224
/// Implementation details for macros.
227225
/// Do not use. Used for macros only. Not covered by semver guarantees.
228226
#[doc(hidden)]

src/mpmc.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,13 @@ 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+
const {
157+
assert!(N > 1);
158+
assert!(N.is_power_of_two());
159+
assert!(N < UintSize::MAX as usize);
160+
}
165161

166162
let mut cell_count = 0;
167163

src/sealed.rs

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

src/sorted_linked_list.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ 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+
const {
241+
assert!(N < $max_val);
242+
}
242243

243244
let mut list = SortedLinkedList {
244245
list: OwnedSortedLinkedListStorage {

src/spsc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ 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+
const {
147+
assert!(N > 1);
148+
}
148149

149150
Queue {
150151
head: AtomicUsize::new(0),

src/vec/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,9 @@ 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+
const {
215+
assert!(N >= M);
216+
}
218217

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

0 commit comments

Comments
 (0)