diff options
| author | bors <bors@rust-lang.org> | 2019-01-22 05:42:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-01-22 05:42:11 +0000 |
| commit | 8e9774ffcf892c85d2e29030c17af1c246e6aa73 (patch) | |
| tree | 38724b06007cd3fa373607c8b4044d9df5329fa4 /src/libcore/tests/nonzero.rs | |
| parent | 51cc3cdcf060c1bf3e4d45947f7a6bc20f9960f7 (diff) | |
| parent | e195ce654a570606a85ead6cefb36042a206205a (diff) | |
Auto merge of #57475 - SimonSapin:signed, r=estebank
Add signed num::NonZeroI* types Multiple people have asked for them in https://github.com/rust-lang/rust/issues/49137. Given that the unsigned ones already exist, they are very easy to add and not an additional maintenance burden.
Diffstat (limited to 'src/libcore/tests/nonzero.rs')
| -rw-r--r-- | src/libcore/tests/nonzero.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libcore/tests/nonzero.rs b/src/libcore/tests/nonzero.rs index c813bf20cb6..4532568ee0c 100644 --- a/src/libcore/tests/nonzero.rs +++ b/src/libcore/tests/nonzero.rs @@ -1,4 +1,4 @@ -use core::num::NonZeroU32; +use core::num::{NonZeroU32, NonZeroI32}; use core::option::Option; use core::option::Option::{Some, None}; use std::mem::size_of; @@ -13,6 +13,7 @@ fn test_create_nonzero_instance() { #[test] fn test_size_nonzero_in_option() { assert_eq!(size_of::<NonZeroU32>(), size_of::<Option<NonZeroU32>>()); + assert_eq!(size_of::<NonZeroI32>(), size_of::<Option<NonZeroI32>>()); } #[test] @@ -118,3 +119,10 @@ fn test_from_nonzero() { let num: u32 = nz.into(); assert_eq!(num, 1u32); } + +#[test] +fn test_from_signed_nonzero() { + let nz = NonZeroI32::new(1).unwrap(); + let num: i32 = nz.into(); + assert_eq!(num, 1i32); +} |
