From: Piotr Jawniak Date: Tue, 13 May 2014 09:00:11 +0000 (+0200) Subject: Implements Default trait for BigInt and BigUint X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=655487b59666afe5a5c9e0a305c27be342b8fa46;p=rust.git Implements Default trait for BigInt and BigUint --- diff --git a/src/libnum/bigint.rs b/src/libnum/bigint.rs index ef6f1aafe88..ac8da664de7 100644 --- a/src/libnum/bigint.rs +++ b/src/libnum/bigint.rs @@ -19,6 +19,7 @@ use Integer; use std::cmp; +use std::default::Default; use std::fmt; use std::from_str::FromStr; use std::num::CheckedDiv; @@ -112,6 +113,11 @@ fn cmp(&self, other: &BigUint) -> Ordering { } } +impl Default for BigUint { + #[inline] + fn default() -> BigUint { BigUint::new(Vec::new()) } +} + impl fmt::Show for BigUint { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f.buf, "{}", self.to_str_radix(10)) @@ -830,6 +836,11 @@ fn cmp(&self, other: &BigInt) -> Ordering { } } +impl Default for BigInt { + #[inline] + fn default() -> BigInt { BigInt::new(Zero, Vec::new()) } +} + impl fmt::Show for BigInt { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f.buf, "{}", self.to_str_radix(10))