diff --git a/Cargo.toml b/Cargo.toml index 3eda19c..cda3b3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,5 @@ authors = ["Zach Dziura "] [dependencies] custom_derive = "0.1.2" newtype_derive = "0.1.2" -ramp = "0.1.9" +ramp = "0.1.*" rand = "0.3.11" diff --git a/examples/multiply.rs b/examples/multiply.rs new file mode 100644 index 0000000..ccfef9c --- /dev/null +++ b/examples/multiply.rs @@ -0,0 +1,11 @@ +extern crate pumpkin; + +use pumpkin::Prime; + +fn main() { + let p = Prime::new(2048); + let q = Prime::new(2048); + let s = p * q; + + println!("{}", s); +} diff --git a/src/lib.rs b/src/lib.rs index 4943f43..aa39758 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,6 @@ #![feature(augmented_assignments)] #![feature(core)] -#![feature(test)] +#![feature(custom_derive)] /// # The Pumpkin Prime Number Generator /// @@ -10,26 +10,20 @@ /// secure source of entrophy and are verified using three different primality /// tests. /// -/// ## Installation -/// -/// To include `pumpkin` in your project add the following line to your -/// Cargo.toml file: -/// -/// ``` -/// [dependencies] -/// pumpkin = "*" -/// ``` -/// /// ## Examples /// /// ``` +/// extern crate pumpkin; +/// +/// use pumpkin::Prime; +/// /// fn main() { /// // Generate a 2048-bit prime number -/// let prime = pumpkin::Prime::new(2048); +/// let p = Prime::new(2048); +/// let q = Prime::new(2048); /// -/// // Want to very the prime you generated is ACTUALLY prime, and not -/// // simply a probable prime? Easy! -/// assert_eq!(prime.verify(), true); +/// let r = p * q; +/// println!("{}", r); // Some ridiculously large number /// } /// ``` @@ -39,4 +33,5 @@ extern crate core; extern crate ramp; extern crate rand; -pub mod prime; +mod prime; +pub use prime::Prime; diff --git a/src/prime.rs b/src/prime.rs index 150269c..8c7b2b4 100644 --- a/src/prime.rs +++ b/src/prime.rs @@ -94,11 +94,10 @@ static SMALL_PRIMES: [u32; 999] = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, /// /// `Prime`s are built upon the `Int` type as defined in the `ramp` crate. In /// fact, all operations that you can do with `Int`s, you can do with `Prime`s -/// as well. `Prime`s simply guarantee that the number you're dealing with is, -/// a prime number. +/// as well. `Prime`s simply claim that the number you're dealing with is a +/// prime number. custom_derive! { - #[derive(Debug)] - #[derive(NewtypeAdd, NewtypeSub, NewtypeMul, NewtypeDiv)] + #[derive(Debug, NewtypeAdd, NewtypeSub, NewtypeMul, NewtypeDiv)] pub struct Prime(Int); } @@ -240,22 +239,3 @@ fn rewrite(candidate: &Int) -> (Int, Int) { (s, d) } - -#[cfg(test)] -mod tests { - extern crate test; - - use super::*; - use self::test::Bencher; - - #[bench] - fn bench_prime_gen_1024(b: &mut Bencher) { - b.iter(|| Prime::new(1024)); - } - - #[bench] - fn bench_prime_gen_2048(b: &mut Bencher) { - b.iter(|| Prime::new(2048)); - } -} -