Skip to content

Commit

Permalink
Add impls for NonZero*
Browse files Browse the repository at this point in the history
Closes #18
  • Loading branch information
aDotInTheVoid committed Jan 3, 2024
1 parent f747bad commit 097ceb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/std_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
use crate::{Debug, Formatter};

macro_rules! std_debug {
($($t:ty),+) => {
($($t:ty),+ ,) => {
$(
impl Debug for $t {
fn fmt(&self, f: &mut Formatter) {
Expand Down Expand Up @@ -43,7 +43,19 @@ std_debug! {
str,
(),
Path,
PathBuf
PathBuf,
std::num::NonZeroI8,
std::num::NonZeroI16,
std::num::NonZeroI32,
std::num::NonZeroI64,
std::num::NonZeroI128,
std::num::NonZeroIsize,
std::num::NonZeroU8,
std::num::NonZeroU16,
std::num::NonZeroU32,
std::num::NonZeroU64,
std::num::NonZeroU128,
std::num::NonZeroUsize,
}

macro_rules! peel {
Expand Down
6 changes: 6 additions & 0 deletions tests/it/std.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{
cell::RefCell,
num::NonZeroI16,
sync::{Arc, Mutex},
};

Expand Down Expand Up @@ -150,3 +151,8 @@ fn range_big() {
expect!["..=[4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]"],
);
}

#[test]
fn nonzero() {
assert_eq!(pprint(NonZeroI16::new(10)), "Some(10)");
}

0 comments on commit 097ceb8

Please sign in to comment.