Skip to content

Commit 097ceb8

Browse files
committed
Add impls for NonZero*
Closes #18
1 parent f747bad commit 097ceb8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/std_impls.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use crate::{Debug, Formatter};
1212

1313
macro_rules! std_debug {
14-
($($t:ty),+) => {
14+
($($t:ty),+ ,) => {
1515
$(
1616
impl Debug for $t {
1717
fn fmt(&self, f: &mut Formatter) {
@@ -43,7 +43,19 @@ std_debug! {
4343
str,
4444
(),
4545
Path,
46-
PathBuf
46+
PathBuf,
47+
std::num::NonZeroI8,
48+
std::num::NonZeroI16,
49+
std::num::NonZeroI32,
50+
std::num::NonZeroI64,
51+
std::num::NonZeroI128,
52+
std::num::NonZeroIsize,
53+
std::num::NonZeroU8,
54+
std::num::NonZeroU16,
55+
std::num::NonZeroU32,
56+
std::num::NonZeroU64,
57+
std::num::NonZeroU128,
58+
std::num::NonZeroUsize,
4759
}
4860

4961
macro_rules! peel {

tests/it/std.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{
22
cell::RefCell,
3+
num::NonZeroI16,
34
sync::{Arc, Mutex},
45
};
56

@@ -150,3 +151,8 @@ fn range_big() {
150151
expect!["..=[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]"],
151152
);
152153
}
154+
155+
#[test]
156+
fn nonzero() {
157+
assert_eq!(pprint(NonZeroI16::new(10)), "Some(10)");
158+
}

0 commit comments

Comments
 (0)