Use generic NonZero internally.

This commit is contained in:
Markus Reiter 2024-01-29 23:59:09 +01:00
parent ee9c7c940c
commit 746a58d435
No known key found for this signature in database
GPG key ID: 245293B51702655B
144 changed files with 653 additions and 604 deletions

View file

@ -11,6 +11,7 @@
#![feature(associated_type_bounds)]
#![feature(const_option)]
#![feature(core_intrinsics)]
#![feature(generic_nonzero)]
#![feature(inline_const)]
#![feature(min_specialization)]
#![feature(never_type)]

View file

@ -6,6 +6,7 @@ use std::cell::{Cell, RefCell};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque};
use std::hash::{BuildHasher, Hash};
use std::marker::PhantomData;
use std::num::NonZero;
use std::path;
use std::rc::Rc;
use std::sync::Arc;
@ -216,15 +217,15 @@ impl<D: Decoder> Decodable<D> for ! {
}
}
impl<S: Encoder> Encodable<S> for ::std::num::NonZeroU32 {
impl<S: Encoder> Encodable<S> for NonZero<u32> {
fn encode(&self, s: &mut S) {
s.emit_u32(self.get());
}
}
impl<D: Decoder> Decodable<D> for ::std::num::NonZeroU32 {
impl<D: Decoder> Decodable<D> for NonZero<u32> {
fn decode(d: &mut D) -> Self {
::std::num::NonZeroU32::new(d.read_u32()).unwrap()
NonZero::<u32>::new(d.read_u32()).unwrap()
}
}