diff --git a/Cargo.toml b/Cargo.toml index 33eaa4f..936839e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "rusty-fib-facts" -version = "0.1.0" +version = "0.2.0" authors = ["Timothy J Warren "] -edition = "2018" +edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] [dev-dependencies] -criterion = "0.3" +criterion = { version="0.3.5", features=["html_reports"] } [[bench]] name = "stock_functions" diff --git a/src/lib.rs b/src/lib.rs index 3a94681..a799a39 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,21 +1,12 @@ //! # Rusty Fib Facts //! -//! Implementations of common math algorithms to benchmark +//! Implementations of common algorithms to benchmark #![forbid(unsafe_code)] -#![no_std] -use core::cmp::{max, min}; +pub mod parallel; -#[cfg(all(feature = "alloc", not(feature = "std")))] -#[macro_use] -extern crate alloc; - -#[cfg(feature = "std")] -#[macro_use] -extern crate std; - -#[cfg(feature = "std")] -use core::f64::consts::{E, PI}; +use std::cmp::{max, min}; +use std::f64::consts::{E, PI}; /// Calculate a number in the fibonacci sequence, /// using recursion and a lookup table @@ -150,7 +141,7 @@ pub fn it_factorial(n: usize) -> Option { } } -/// Calculate the value of a factorial recrursively +/// Calculate the value of a factorial recursively /// /// Can calculate up to 34! using native unsigned 128 bit integers. /// @@ -191,7 +182,6 @@ pub fn factorial(n: usize) -> Option { /// let invalid = approx_factorial(171.0); // None /// # assert!(invalid.is_none()); /// ``` -#[cfg(feature = "std")] #[inline] pub fn approx_factorial(n: f64) -> Option { let power = (n / E).powf(n); @@ -199,7 +189,7 @@ pub fn approx_factorial(n: f64) -> Option { let res = power * root; - if res >= core::f64::MIN && res <= core::f64::MAX { + if res >= std::f64::MIN && res <= std::f64::MAX { Some(res) } else { None @@ -335,7 +325,6 @@ mod tests { assert!(it_factorial(35).is_none()); } - #[cfg(feature = "std")] #[test] fn test_approx_factorial() { assert!(approx_factorial(170.624).is_some());