File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,8 @@ define_valid_range_type! {
131
131
pub struct NonZeroI32Inner(i32 as u32 in 1..=0xffff_ffff);
132
132
pub struct NonZeroI64Inner(i64 as u64 in 1..=0xffffffff_ffffffff);
133
133
pub struct NonZeroI128Inner(i128 as u128 in 1..=0xffffffffffffffff_ffffffffffffffff);
134
+
135
+ pub struct NonZeroCharInner(char as u32 in 1..=0x10ffff);
134
136
}
135
137
136
138
#[cfg(target_pointer_width = "16")]
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ impl_zeroable_primitive!(
79
79
NonZeroI64Inner(i64),
80
80
NonZeroI128Inner(i128),
81
81
NonZeroIsizeInner(isize),
82
+ NonZeroCharInner(char),
82
83
);
83
84
84
85
/// A value that is known not to equal zero.
Original file line number Diff line number Diff line change @@ -22,20 +22,19 @@ mod u64;
22
22
mod u8;
23
23
24
24
mod bignum;
25
-
26
25
mod const_from;
27
26
mod dec2flt;
27
+ mod float_iter_sum_identity;
28
28
mod flt2dec;
29
+ mod ieee754;
29
30
mod int_log;
30
31
mod int_sqrt;
31
32
mod midpoint;
33
+ mod nan;
34
+ mod niche_types;
32
35
mod ops;
33
36
mod wrapping;
34
37
35
- mod float_iter_sum_identity;
36
- mod ieee754;
37
- mod nan;
38
-
39
38
/// Adds the attribute to all items in the block.
40
39
macro_rules! cfg_block {
41
40
($(#[$attr:meta]{$($it:item)*})*) => {$($(
Original file line number Diff line number Diff line change
1
+ use core::num::NonZero;
2
+
3
+ #[test]
4
+ fn test_new_from_zero_is_none() {
5
+ assert_eq!(NonZero::<char>::new(0 as char), None);
6
+ }
7
+
8
+ #[test]
9
+ fn test_new_from_extreme_is_some() {
10
+ assert!(NonZero::<char>::new(1 as char).is_some());
11
+ assert!(NonZero::<char>::new(char::MAX).is_some());
12
+ }
You can’t perform that action at this time.
0 commit comments