diff options
| author | Piotr Jawniak <sawyer47@gmail.com> | 2014-05-13 11:00:11 +0200 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-05-13 17:24:07 -0700 |
| commit | 655487b59666afe5a5c9e0a305c27be342b8fa46 (patch) | |
| tree | 4962650f622d16cfa97b79e8c7a22b6c8982b57a /src/libnum | |
| parent | a390b5dd0320957b00177c8ae837c51ceb737fef (diff) | |
| download | rust-655487b59666afe5a5c9e0a305c27be342b8fa46.tar.gz rust-655487b59666afe5a5c9e0a305c27be342b8fa46.zip | |
Implements Default trait for BigInt and BigUint
Diffstat (limited to 'src/libnum')
| -rw-r--r-- | src/libnum/bigint.rs | 11 |
1 files changed, 11 insertions, 0 deletions
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 @@ A `BigInt` is a combination of `BigUint` and `Sign`. 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 @@ impl TotalOrd for BigUint { } } +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 @@ impl TotalOrd for BigInt { } } +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)) |
