Skip to content

Commit

Permalink
More descriptive feature flag names
Browse files Browse the repository at this point in the history
  • Loading branch information
JSorngard committed Jul 28, 2024
1 parent 142dd50 commit e2160b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ repository = "https://github.com/JSorngard/lambert_w"
approx = "0.5.1"

[features]
default = ["24", "50"]
default = ["24bits", "50bits"]
# Enables the function versions with 50 bits of accuracy.
50 = []
50bits = []
# Enables the function versions with 24 bits of accuracy.
24 = []
24bits = []

# docs.rs-specific configuration. Taken from <https://stackoverflow.com/a/61417700/>.
[package.metadata.docs.rs]
Expand Down
30 changes: 15 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//!
//! Evaluate the principal branch of the Lambert W function to 50 bits of accuracy:
#![cfg_attr(
feature = "50",
feature = "50bits",
doc = r##"
```
use lambert_w::accurate::lambert_w_0;
Expand All @@ -26,7 +26,7 @@ assert_abs_diff_eq!(w, 1.0736581947961492);
//!
//! or to only 24 bits of accuracy, but with faster execution time:
#![cfg_attr(
feature = "24",
feature = "24bits",
doc = r##"
```
use lambert_w::fast::lambert_w_0;
Expand All @@ -49,20 +49,20 @@ assert_abs_diff_eq!(w, 1.0736581947961492, epsilon = 1e-7);
//!
//! You can disable one of these feature flags to potentially save a little bit of binary size.
//!
//! `50` *(enabled by default)*: enables the function versions with 50 bits of accuracy.
//! `50bits` *(enabled by default)*: enables the more accurate function versions with 50 bits of accuracy.
//!
//! `24` *(enabled by default)*: enables the function versions with 24 bits of accuracy.
//! `24bits` *(enabled by default)*: enables the faster function versions with 24 bits of accuracy.
//!
//! It is a compile error to disable both features.
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

#[cfg(not(any(feature = "50", feature = "24")))]
compile_error!("one or both of the '24' and '50' features must be enabled");
#[cfg(not(any(feature = "50bits", feature = "24bits")))]
compile_error!("one or both of the '24bits' and '50bits' features must be enabled");

#[cfg(feature = "50")]
#[cfg(feature = "50bits")]
pub mod accurate;
#[cfg(feature = "24")]
#[cfg(feature = "24bits")]
pub mod fast;

// -1/e
Expand All @@ -71,16 +71,16 @@ const Z0: f64 = -0.367_879_441_171_442_33;
// 1/sqrt(e)
const X0: f64 = 0.606_530_659_712_633_4;

#[cfg(all(test, any(feature = "24", feature = "50")))]
#[cfg(all(test, any(feature = "24bits", feature = "50bits")))]
mod tets {
#[cfg(feature = "50")]
#[cfg(feature = "50bits")]
use super::accurate::{lambert_w_0 as lambert_w_0_50, lambert_w_m1 as lambert_w_m1_50};
#[cfg(feature = "24")]
#[cfg(feature = "24bits")]
use super::fast::{lambert_w_0 as lambert_w_0_24, lambert_w_m1 as lambert_w_m1_24};
use approx::assert_abs_diff_eq;
use core::f64::consts::E;

#[cfg(feature = "50")]
#[cfg(feature = "50bits")]
#[test]
fn test_lambert_w_0_50() {
assert_eq!(lambert_w_0_50(-1.0 / E - f64::EPSILON), None);
Expand Down Expand Up @@ -203,7 +203,7 @@ mod tets {
);
}

#[cfg(feature = "24")]
#[cfg(feature = "24bits")]
#[test]
fn test_lambert_w_0_24() {
assert_eq!(lambert_w_0_24(-1.0 / E - f64::EPSILON), None);
Expand Down Expand Up @@ -339,7 +339,7 @@ mod tets {
);
}

#[cfg(feature = "50")]
#[cfg(feature = "50bits")]
#[test]
fn test_lambert_w_m1_50() {
assert_eq!(lambert_w_m1_50(-1.0 / E - f64::EPSILON), None);
Expand Down Expand Up @@ -408,7 +408,7 @@ mod tets {
assert_eq!(lambert_w_m1_50(f64::EPSILON), None);
}

#[cfg(feature = "24")]
#[cfg(feature = "24bits")]
#[test]
fn test_lambert_w_m1_24() {
assert_eq!(lambert_w_m1_24(-1.0 / E - f64::EPSILON), None);
Expand Down

0 comments on commit e2160b4

Please sign in to comment.