Merge pull request #29 from gifnksm/master

Implements `Encodable` and `Decodable`
This commit is contained in:
Alex Crichton 2014-11-13 10:44:46 -06:00
commit aec75185e5
4 changed files with 6 additions and 5 deletions

View File

@ -112,7 +112,7 @@ pub mod BigDigit {
/// ///
/// A `BigUint`-typed value `BigUint { data: vec!(a, b, c) }` represents a number /// A `BigUint`-typed value `BigUint { data: vec!(a, b, c) }` represents a number
/// `(a + b * BigDigit::BASE + c * BigDigit::BASE^2)`. /// `(a + b * BigDigit::BASE + c * BigDigit::BASE^2)`.
#[deriving(Clone)] #[deriving(Clone, Encodable, Decodable)]
pub struct BigUint { pub struct BigUint {
data: Vec<BigDigit> data: Vec<BigDigit>
} }
@ -843,7 +843,7 @@ fn get_radix_base(radix: uint) -> (DoubleBigDigit, uint) {
} }
/// A Sign is a `BigInt`'s composing element. /// A Sign is a `BigInt`'s composing element.
#[deriving(PartialEq, PartialOrd, Eq, Ord, Clone, Show)] #[deriving(PartialEq, PartialOrd, Eq, Ord, Clone, Show, Encodable, Decodable)]
pub enum Sign { Minus, NoSign, Plus } pub enum Sign { Minus, NoSign, Plus }
impl Neg<Sign> for Sign { impl Neg<Sign> for Sign {
@ -859,7 +859,7 @@ impl Neg<Sign> for Sign {
} }
/// A big signed integer type. /// A big signed integer type.
#[deriving(Clone)] #[deriving(Clone, Encodable, Decodable)]
pub struct BigInt { pub struct BigInt {
sign: Sign, sign: Sign,
data: BigUint data: BigUint

View File

@ -18,7 +18,7 @@ use std::num::{Zero, One};
// probably doesn't map to C's _Complex correctly. // probably doesn't map to C's _Complex correctly.
/// A complex number in Cartesian form. /// A complex number in Cartesian form.
#[deriving(PartialEq, Clone, Hash)] #[deriving(PartialEq, Clone, Hash, Encodable, Decodable)]
pub struct Complex<T> { pub struct Complex<T> {
/// Real portion of the complex number /// Real portion of the complex number
pub re: T, pub re: T,

View File

@ -58,6 +58,7 @@
#![allow(deprecated)] // from_str_radix #![allow(deprecated)] // from_str_radix
extern crate rand; extern crate rand;
extern crate serialize;
pub use bigint::{BigInt, BigUint}; pub use bigint::{BigInt, BigUint};
pub use rational::{Rational, BigRational}; pub use rational::{Rational, BigRational};

View File

@ -21,7 +21,7 @@ use std::num::{Zero, One, FromStrRadix};
use bigint::{BigInt, BigUint, Sign, Plus, Minus}; use bigint::{BigInt, BigUint, Sign, Plus, Minus};
/// Represents the ratio between 2 numbers. /// Represents the ratio between 2 numbers.
#[deriving(Clone, Hash)] #[deriving(Clone, Hash, Encodable, Decodable)]
#[allow(missing_docs)] #[allow(missing_docs)]
pub struct Ratio<T> { pub struct Ratio<T> {
numer: T, numer: T,