diff options
| author | bors <bors@rust-lang.org> | 2024-02-16 07:46:31 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-16 07:46:31 +0000 |
| commit | 1be468815cb7c6932fcc7ed3ee81e6a14376c05e (patch) | |
| tree | b0b4d37f0274c53c54e2245a73973c6ba1db47bd /library/std/src/thread/mod.rs | |
| parent | 0f806a9812b62c36bdab08d33c14cf2d3ecf4355 (diff) | |
| parent | a90cc05233858fcd16c3ca0e0b4320fc5ae09af2 (diff) | |
| download | rust-1be468815cb7c6932fcc7ed3ee81e6a14376c05e.tar.gz rust-1be468815cb7c6932fcc7ed3ee81e6a14376c05e.zip | |
Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnay
Use generic `NonZero` internally. Tracking issue: https://github.com/rust-lang/rust/issues/120257
Diffstat (limited to 'library/std/src/thread/mod.rs')
| -rw-r--r-- | library/std/src/thread/mod.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index eb837c8f6c6..4f0f010984a 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -165,8 +165,7 @@ use crate::fmt; use crate::io; use crate::marker::PhantomData; use crate::mem::{self, forget}; -use crate::num::NonZeroU64; -use crate::num::NonZeroUsize; +use crate::num::{NonZero, NonZeroU64, NonZeroUsize}; use crate::panic; use crate::panicking; use crate::pin::Pin; @@ -1166,7 +1165,7 @@ pub fn park_timeout(dur: Duration) { /// [`id`]: Thread::id #[stable(feature = "thread_id", since = "1.19.0")] #[derive(Eq, PartialEq, Clone, Copy, Hash, Debug)] -pub struct ThreadId(NonZeroU64); +pub struct ThreadId(NonZero<u64>); impl ThreadId { // Generate a new unique thread ID. @@ -1189,7 +1188,7 @@ impl ThreadId { }; match COUNTER.compare_exchange_weak(last, id, Relaxed, Relaxed) { - Ok(_) => return ThreadId(NonZeroU64::new(id).unwrap()), + Ok(_) => return ThreadId(NonZero::new(id).unwrap()), Err(id) => last = id, } } @@ -1208,7 +1207,7 @@ impl ThreadId { *counter = id; drop(counter); - ThreadId(NonZeroU64::new(id).unwrap()) + ThreadId(NonZero::new(id).unwrap()) } } } |
