Skip to content

Commit 1d52ab9

Browse files
committed
feat: RacyStorage public trait
1 parent 0cce0ef commit 1d52ab9

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

ecmascript_atomics/src/lib.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ use unordered_copy::*;
9191

9292
use crate::private::Sealed;
9393

94+
/// Public trait for allowing users of the library to name the types that can
95+
/// be natively stored in racy memory. These are effectively the unsigned
96+
/// integers from 1 to 8 bytes in size.
97+
pub trait RacyStorage: Sealed {}
98+
99+
impl RacyStorage for u8 {}
100+
impl RacyStorage for u16 {}
101+
impl RacyStorage for u32 {}
102+
impl RacyStorage for u64 {}
103+
impl RacyStorage for usize {}
104+
94105
/// ECMAScript atomic memory orderings
95106
///
96107
/// Memory orderings specify the way atomic operations synchronise memory.
@@ -308,14 +319,14 @@ impl<T: Sealed> RacyMemory<T> {
308319
}
309320

310321
mod private {
311-
pub trait Sealed: Copy + core::fmt::Debug {}
312-
}
322+
pub trait Sealed: Copy + Eq + Send + Sync + core::fmt::Display {}
313323

314-
impl Sealed for u8 {}
315-
impl Sealed for u16 {}
316-
impl Sealed for u32 {}
317-
impl Sealed for u64 {}
318-
impl Sealed for usize {}
324+
impl Sealed for u8 {}
325+
impl Sealed for u16 {}
326+
impl Sealed for u32 {}
327+
impl Sealed for u64 {}
328+
impl Sealed for usize {}
329+
}
319330

320331
/// Opaque handle to a slice of memory with the ECMAScript Atomics memory
321332
/// model.

0 commit comments

Comments
 (0)