Convert statics to constants

This commit is contained in:
gifnksm 2014-10-10 22:50:22 +09:00
parent 9b6e014a8b
commit 2fe050c471
3 changed files with 21 additions and 21 deletions

View File

@ -75,7 +75,7 @@ pub type BigDigit = u32;
/// size is the double of the size of `BigDigit`. /// size is the double of the size of `BigDigit`.
pub type DoubleBigDigit = u64; pub type DoubleBigDigit = u64;
pub static ZERO_BIG_DIGIT: BigDigit = 0; pub const ZERO_BIG_DIGIT: BigDigit = 0;
static ZERO_VEC: [BigDigit, ..1] = [ZERO_BIG_DIGIT]; static ZERO_VEC: [BigDigit, ..1] = [ZERO_BIG_DIGIT];
#[allow(non_snake_case)] #[allow(non_snake_case)]
@ -84,10 +84,10 @@ pub mod BigDigit {
use super::DoubleBigDigit; use super::DoubleBigDigit;
// `DoubleBigDigit` size dependent // `DoubleBigDigit` size dependent
pub static bits: uint = 32; pub const bits: uint = 32;
pub static base: DoubleBigDigit = 1 << bits; pub const base: DoubleBigDigit = 1 << bits;
static lo_mask: DoubleBigDigit = (-1 as DoubleBigDigit) >> bits; const lo_mask: DoubleBigDigit = (-1 as DoubleBigDigit) >> bits;
#[inline] #[inline]
fn get_hi(n: DoubleBigDigit) -> BigDigit { (n >> bits) as BigDigit } fn get_hi(n: DoubleBigDigit) -> BigDigit { (n >> bits) as BigDigit }

View File

@ -194,13 +194,13 @@ mod test {
use std::num::{Zero, One, Float}; use std::num::{Zero, One, Float};
use std::hash::hash; use std::hash::hash;
pub static _0_0i : Complex64 = Complex { re: 0.0, im: 0.0 }; pub const _0_0i : Complex64 = Complex { re: 0.0, im: 0.0 };
pub static _1_0i : Complex64 = Complex { re: 1.0, im: 0.0 }; pub const _1_0i : Complex64 = Complex { re: 1.0, im: 0.0 };
pub static _1_1i : Complex64 = Complex { re: 1.0, im: 1.0 }; pub const _1_1i : Complex64 = Complex { re: 1.0, im: 1.0 };
pub static _0_1i : Complex64 = Complex { re: 0.0, im: 1.0 }; pub const _0_1i : Complex64 = Complex { re: 0.0, im: 1.0 };
pub static _neg1_1i : Complex64 = Complex { re: -1.0, im: 1.0 }; pub const _neg1_1i : Complex64 = Complex { re: -1.0, im: 1.0 };
pub static _05_05i : Complex64 = Complex { re: 0.5, im: 0.5 }; pub const _05_05i : Complex64 = Complex { re: 0.5, im: 0.5 };
pub static all_consts : [Complex64, .. 5] = [_0_0i, _1_0i, _1_1i, _neg1_1i, _05_05i]; pub const all_consts : [Complex64, .. 5] = [_0_0i, _1_0i, _1_1i, _neg1_1i, _05_05i];
#[test] #[test]
fn test_consts() { fn test_consts() {

View File

@ -401,16 +401,16 @@ mod test {
use std::num; use std::num;
use std::i32; use std::i32;
pub static _0 : Rational = Ratio { numer: 0, denom: 1}; pub const _0 : Rational = Ratio { numer: 0, denom: 1};
pub static _1 : Rational = Ratio { numer: 1, denom: 1}; pub const _1 : Rational = Ratio { numer: 1, denom: 1};
pub static _2: Rational = Ratio { numer: 2, denom: 1}; pub const _2: Rational = Ratio { numer: 2, denom: 1};
pub static _1_2: Rational = Ratio { numer: 1, denom: 2}; pub const _1_2: Rational = Ratio { numer: 1, denom: 2};
pub static _3_2: Rational = Ratio { numer: 3, denom: 2}; pub const _3_2: Rational = Ratio { numer: 3, denom: 2};
pub static _neg1_2: Rational = Ratio { numer: -1, denom: 2}; pub const _neg1_2: Rational = Ratio { numer: -1, denom: 2};
pub static _1_3: Rational = Ratio { numer: 1, denom: 3}; pub const _1_3: Rational = Ratio { numer: 1, denom: 3};
pub static _neg1_3: Rational = Ratio { numer: -1, denom: 3}; pub const _neg1_3: Rational = Ratio { numer: -1, denom: 3};
pub static _2_3: Rational = Ratio { numer: 2, denom: 3}; pub const _2_3: Rational = Ratio { numer: 2, denom: 3};
pub static _neg2_3: Rational = Ratio { numer: -2, denom: 3}; pub const _neg2_3: Rational = Ratio { numer: -2, denom: 3};
pub fn to_big(n: Rational) -> BigRational { pub fn to_big(n: Rational) -> BigRational {
Ratio::new( Ratio::new(