Skip to content

Commit c294d64

Browse files
authored
Merge pull request #280 from briansmith/b/self
race: Use `Self` ubiquitously.
2 parents 5f0fdd4 + 9df68c0 commit c294d64

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/race.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ pub struct OnceNonZeroUsize {
4747
impl OnceNonZeroUsize {
4848
/// Creates a new empty cell.
4949
#[inline]
50-
pub const fn new() -> OnceNonZeroUsize {
51-
OnceNonZeroUsize { inner: AtomicUsize::new(0) }
50+
pub const fn new() -> Self {
51+
Self { inner: AtomicUsize::new(0) }
5252
}
5353

5454
/// Gets the underlying value.
@@ -169,14 +169,14 @@ pub struct OnceBool {
169169
impl OnceBool {
170170
/// Creates a new empty cell.
171171
#[inline]
172-
pub const fn new() -> OnceBool {
173-
OnceBool { inner: OnceNonZeroUsize::new() }
172+
pub const fn new() -> Self {
173+
Self { inner: OnceNonZeroUsize::new() }
174174
}
175175

176176
/// Gets the underlying value.
177177
#[inline]
178178
pub fn get(&self) -> Option<bool> {
179-
self.inner.get().map(OnceBool::from_usize)
179+
self.inner.get().map(Self::from_usize)
180180
}
181181

182182
/// Sets the contents of this cell to `value`.
@@ -185,7 +185,7 @@ impl OnceBool {
185185
/// full.
186186
#[inline]
187187
pub fn set(&self, value: bool) -> Result<(), ()> {
188-
self.inner.set(OnceBool::to_usize(value))
188+
self.inner.set(Self::to_usize(value))
189189
}
190190

191191
/// Gets the contents of the cell, initializing it with `f` if the cell was
@@ -198,7 +198,7 @@ impl OnceBool {
198198
where
199199
F: FnOnce() -> bool,
200200
{
201-
OnceBool::from_usize(self.inner.get_or_init(|| OnceBool::to_usize(f())))
201+
Self::from_usize(self.inner.get_or_init(|| Self::to_usize(f())))
202202
}
203203

204204
/// Gets the contents of the cell, initializing it with `f` if
@@ -212,7 +212,7 @@ impl OnceBool {
212212
where
213213
F: FnOnce() -> Result<bool, E>,
214214
{
215-
self.inner.get_or_try_init(|| f().map(OnceBool::to_usize)).map(OnceBool::from_usize)
215+
self.inner.get_or_try_init(|| f().map(Self::to_usize)).map(Self::from_usize)
216216
}
217217

218218
#[inline]
@@ -249,8 +249,8 @@ impl<'a, T> Default for OnceRef<'a, T> {
249249

250250
impl<'a, T> OnceRef<'a, T> {
251251
/// Creates a new empty cell.
252-
pub const fn new() -> OnceRef<'a, T> {
253-
OnceRef { inner: AtomicPtr::new(ptr::null_mut()), ghost: PhantomData }
252+
pub const fn new() -> Self {
253+
Self { inner: AtomicPtr::new(ptr::null_mut()), ghost: PhantomData }
254254
}
255255

256256
/// Gets a reference to the underlying value.
@@ -377,13 +377,13 @@ mod once_box {
377377

378378
impl<T> OnceBox<T> {
379379
/// Creates a new empty cell.
380-
pub const fn new() -> OnceBox<T> {
381-
OnceBox { inner: AtomicPtr::new(ptr::null_mut()), ghost: PhantomData }
380+
pub const fn new() -> Self {
381+
Self { inner: AtomicPtr::new(ptr::null_mut()), ghost: PhantomData }
382382
}
383383

384384
/// Creates a new cell with the given value.
385385
pub fn with_value(value: Box<T>) -> Self {
386-
OnceBox { inner: AtomicPtr::new(Box::into_raw(value)), ghost: PhantomData }
386+
Self { inner: AtomicPtr::new(Box::into_raw(value)), ghost: PhantomData }
387387
}
388388

389389
/// Gets a reference to the underlying value.

0 commit comments

Comments
 (0)