fix(math): update once_cell::Lazy -> std::sync::LazyLock
This commit is contained in:
parent
2db41703b3
commit
b641c4e686
3 changed files with 14 additions and 13 deletions
|
|
@ -12,7 +12,6 @@ authors = ["Andrew Westberg <andrewwestberg@gmail.com>"]
|
||||||
exclude = ["tests/data/*"]
|
exclude = ["tests/data/*"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
once_cell = "1.19.0"
|
|
||||||
malachite = "0.4.16"
|
malachite = "0.4.16"
|
||||||
malachite-base = "0.4.16"
|
malachite-base = "0.4.16"
|
||||||
regex = "1.10.5"
|
regex = "1.10.5"
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,16 @@
|
||||||
# Cardano Math functions
|
# Cardano Math functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use std::fmt::{Debug, Display};
|
use std::fmt::{Debug, Display};
|
||||||
use std::ops::{Div, Mul, Neg, Sub};
|
use std::ops::{Div, Mul, Neg, Sub};
|
||||||
|
use std::sync::LazyLock;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
pub type FixedDecimal = crate::math_malachite::Decimal;
|
pub type FixedDecimal = crate::math_malachite::Decimal;
|
||||||
|
|
||||||
pub static ZERO: Lazy<FixedDecimal> = Lazy::new(|| FixedDecimal::from(0u64));
|
pub static ZERO: LazyLock<FixedDecimal> = LazyLock::new(|| FixedDecimal::from(0u64));
|
||||||
pub static MINUS_ONE: Lazy<FixedDecimal> = Lazy::new(|| FixedDecimal::from(-1i64));
|
pub static MINUS_ONE: LazyLock<FixedDecimal> = LazyLock::new(|| FixedDecimal::from(-1i64));
|
||||||
pub static ONE: Lazy<FixedDecimal> = Lazy::new(|| FixedDecimal::from(1u64));
|
pub static ONE: LazyLock<FixedDecimal> = LazyLock::new(|| FixedDecimal::from(1u64));
|
||||||
|
|
||||||
#[derive(Debug, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@ use malachite::platform_64::Limb;
|
||||||
use malachite::rounding_modes::RoundingMode;
|
use malachite::rounding_modes::RoundingMode;
|
||||||
use malachite::{Integer, Natural};
|
use malachite::{Integer, Natural};
|
||||||
use malachite_base::num::arithmetic::traits::{Parity, Sign};
|
use malachite_base::num::arithmetic::traits::{Parity, Sign};
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Decimal {
|
pub struct Decimal {
|
||||||
|
|
@ -442,13 +442,15 @@ impl Constant {
|
||||||
unsafe impl Sync for Constant {}
|
unsafe impl Sync for Constant {}
|
||||||
unsafe impl Send for Constant {}
|
unsafe impl Send for Constant {}
|
||||||
|
|
||||||
static DIGITS_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"^-?\d+$").unwrap());
|
static DIGITS_REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"^-?\d+$").unwrap());
|
||||||
static TEN: Lazy<Constant> = Lazy::new(|| Constant::new(|| Integer::from(10)));
|
static TEN: LazyLock<Constant> = LazyLock::new(|| Constant::new(|| Integer::from(10)));
|
||||||
static PRECISION: Lazy<Constant> = Lazy::new(|| Constant::new(|| TEN.value.clone().pow(34)));
|
static PRECISION: LazyLock<Constant> =
|
||||||
static EPS: Lazy<Constant> = Lazy::new(|| Constant::new(|| TEN.value.clone().pow(34 - 24)));
|
LazyLock::new(|| Constant::new(|| TEN.value.clone().pow(34)));
|
||||||
static ONE: Lazy<Constant> = Lazy::new(|| Constant::new(|| Integer::from(1) * &PRECISION.value));
|
static EPS: LazyLock<Constant> = LazyLock::new(|| Constant::new(|| TEN.value.clone().pow(34 - 24)));
|
||||||
static ZERO: Lazy<Constant> = Lazy::new(|| Constant::new(|| Integer::from(0)));
|
static ONE: LazyLock<Constant> =
|
||||||
static E: Lazy<Constant> = Lazy::new(|| {
|
LazyLock::new(|| Constant::new(|| Integer::from(1) * &PRECISION.value));
|
||||||
|
static ZERO: LazyLock<Constant> = LazyLock::new(|| Constant::new(|| Integer::from(0)));
|
||||||
|
static E: LazyLock<Constant> = LazyLock::new(|| {
|
||||||
Constant::new(|| {
|
Constant::new(|| {
|
||||||
let mut e = Integer::from(0);
|
let mut e = Integer::from(0);
|
||||||
ref_exp(&mut e, &ONE.value);
|
ref_exp(&mut e, &ONE.value);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue