Use generic NonZero
internally.
This commit is contained in:
parent
ee9c7c940c
commit
746a58d435
144 changed files with 653 additions and 604 deletions
|
@ -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::<u64>::new(id).unwrap()),
|
||||
Err(id) => last = id,
|
||||
}
|
||||
}
|
||||
|
@ -1208,7 +1207,7 @@ impl ThreadId {
|
|||
|
||||
*counter = id;
|
||||
drop(counter);
|
||||
ThreadId(NonZeroU64::new(id).unwrap())
|
||||
ThreadId(NonZero::<u64>::new(id).unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue