From 41609419c04de6bd52754f68a32e56a357e4d060 Mon Sep 17 00:00:00 2001 From: Arthur Gautier Date: Thu, 15 May 2025 09:39:22 -0700 Subject: [PATCH] implement `From for NonZero` --- src/non_zero.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/non_zero.rs b/src/non_zero.rs index e76b5b970..46f54f045 100644 --- a/src/non_zero.rs +++ b/src/non_zero.rs @@ -1,6 +1,6 @@ //! Wrapper type for non-zero integers. -use crate::{Bounded, ConstChoice, Constants, Encoding, Int, Limb, Uint, Zero}; +use crate::{Bounded, ConstChoice, Constants, Encoding, Int, Limb, Odd, Uint, Zero}; use core::{ fmt, num::{NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128}, @@ -310,6 +310,12 @@ impl From for NonZero> { } } +impl From> for NonZero { + fn from(odd: Odd) -> NonZero { + NonZero(odd.get()) + } +} + impl fmt::Display for NonZero where T: fmt::Display,