Skip to content

Commit

Permalink
Implements Default trait for BigInt and BigUint
Browse files Browse the repository at this point in the history
  • Loading branch information
Sawyer47 authored and alexcrichton committed May 14, 2014
1 parent a390b5d commit 655487b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/libnum/bigint.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 655487b

Please sign in to comment.