diff --git a/pallas-math/Cargo.toml b/pallas-math/Cargo.toml index 2b4861d0..589ce538 100644 --- a/pallas-math/Cargo.toml +++ b/pallas-math/Cargo.toml @@ -12,7 +12,6 @@ authors = ["Andrew Westberg "] exclude = ["tests/data/*"] [dependencies] -once_cell = "1.19.0" malachite = "0.4.16" malachite-base = "0.4.16" regex = "1.10.5" diff --git a/pallas-math/src/math.rs b/pallas-math/src/math.rs index 23ce33bf..6877dde8 100644 --- a/pallas-math/src/math.rs +++ b/pallas-math/src/math.rs @@ -2,16 +2,16 @@ # Cardano Math functions */ -use once_cell::sync::Lazy; use std::fmt::{Debug, Display}; use std::ops::{Div, Mul, Neg, Sub}; +use std::sync::LazyLock; use thiserror::Error; pub type FixedDecimal = crate::math_malachite::Decimal; -pub static ZERO: Lazy = Lazy::new(|| FixedDecimal::from(0u64)); -pub static MINUS_ONE: Lazy = Lazy::new(|| FixedDecimal::from(-1i64)); -pub static ONE: Lazy = Lazy::new(|| FixedDecimal::from(1u64)); +pub static ZERO: LazyLock = LazyLock::new(|| FixedDecimal::from(0u64)); +pub static MINUS_ONE: LazyLock = LazyLock::new(|| FixedDecimal::from(-1i64)); +pub static ONE: LazyLock = LazyLock::new(|| FixedDecimal::from(1u64)); #[derive(Debug, Error)] pub enum Error { diff --git a/pallas-math/src/math_malachite.rs b/pallas-math/src/math_malachite.rs index 545c62e0..4d32bfd9 100644 --- a/pallas-math/src/math_malachite.rs +++ b/pallas-math/src/math_malachite.rs @@ -9,12 +9,12 @@ use malachite::platform_64::Limb; use malachite::rounding_modes::RoundingMode; use malachite::{Integer, Natural}; use malachite_base::num::arithmetic::traits::{Parity, Sign}; -use once_cell::sync::Lazy; use regex::Regex; use std::cmp::Ordering; use std::fmt::{Display, Formatter}; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; use std::str::FromStr; +use std::sync::LazyLock; #[derive(Debug, Clone)] pub struct Decimal { @@ -442,13 +442,15 @@ impl Constant { unsafe impl Sync for Constant {} unsafe impl Send for Constant {} -static DIGITS_REGEX: Lazy = Lazy::new(|| Regex::new(r"^-?\d+$").unwrap()); -static TEN: Lazy = Lazy::new(|| Constant::new(|| Integer::from(10))); -static PRECISION: Lazy = Lazy::new(|| Constant::new(|| TEN.value.clone().pow(34))); -static EPS: Lazy = Lazy::new(|| Constant::new(|| TEN.value.clone().pow(34 - 24))); -static ONE: Lazy = Lazy::new(|| Constant::new(|| Integer::from(1) * &PRECISION.value)); -static ZERO: Lazy = Lazy::new(|| Constant::new(|| Integer::from(0))); -static E: Lazy = Lazy::new(|| { +static DIGITS_REGEX: LazyLock = LazyLock::new(|| Regex::new(r"^-?\d+$").unwrap()); +static TEN: LazyLock = LazyLock::new(|| Constant::new(|| Integer::from(10))); +static PRECISION: LazyLock = + LazyLock::new(|| Constant::new(|| TEN.value.clone().pow(34))); +static EPS: LazyLock = LazyLock::new(|| Constant::new(|| TEN.value.clone().pow(34 - 24))); +static ONE: LazyLock = + LazyLock::new(|| Constant::new(|| Integer::from(1) * &PRECISION.value)); +static ZERO: LazyLock = LazyLock::new(|| Constant::new(|| Integer::from(0))); +static E: LazyLock = LazyLock::new(|| { Constant::new(|| { let mut e = Integer::from(0); ref_exp(&mut e, &ONE.value);