New constants for Dynamic.
This commit is contained in:
parent
94674679d9
commit
ffb1531e0e
@ -9,6 +9,7 @@ Enhancements
|
|||||||
|
|
||||||
* `$symbol$` is supported in custom syntax to match any symbol.
|
* `$symbol$` is supported in custom syntax to match any symbol.
|
||||||
* `Dynamic::as_string` and `Dynamic::as_immutable_string` are deprecated and replaced by `into_string` and `into_immutable_string` respectively.
|
* `Dynamic::as_string` and `Dynamic::as_immutable_string` are deprecated and replaced by `into_string` and `into_immutable_string` respectively.
|
||||||
|
* Added a number of constants to `Dynamic`.
|
||||||
* `parse_float()`, `PI()` and `E()` now defer to `Decimal` under `no_float` if `decimal` is turned on.
|
* `parse_float()`, `PI()` and `E()` now defer to `Decimal` under `no_float` if `decimal` is turned on.
|
||||||
|
|
||||||
|
|
||||||
|
@ -830,8 +830,14 @@ impl Dynamic {
|
|||||||
pub const ONE: Dynamic = Self(Union::Int(1, DEFAULT_TAG_VALUE, ReadWrite));
|
pub const ONE: Dynamic = Self(Union::Int(1, DEFAULT_TAG_VALUE, ReadWrite));
|
||||||
/// A [`Dynamic`] containing the integer two.
|
/// A [`Dynamic`] containing the integer two.
|
||||||
pub const TWO: Dynamic = Self(Union::Int(2, DEFAULT_TAG_VALUE, ReadWrite));
|
pub const TWO: Dynamic = Self(Union::Int(2, DEFAULT_TAG_VALUE, ReadWrite));
|
||||||
|
/// A [`Dynamic`] containing the integer three.
|
||||||
|
pub const THREE: Dynamic = Self(Union::Int(3, DEFAULT_TAG_VALUE, ReadWrite));
|
||||||
/// A [`Dynamic`] containing the integer ten.
|
/// A [`Dynamic`] containing the integer ten.
|
||||||
pub const TEN: Dynamic = Self(Union::Int(10, DEFAULT_TAG_VALUE, ReadWrite));
|
pub const TEN: Dynamic = Self(Union::Int(10, DEFAULT_TAG_VALUE, ReadWrite));
|
||||||
|
/// A [`Dynamic`] containing the integer one hundred.
|
||||||
|
pub const HUNDRED: Dynamic = Self(Union::Int(100, DEFAULT_TAG_VALUE, ReadWrite));
|
||||||
|
/// A [`Dynamic`] containing the integer one thousand.
|
||||||
|
pub const THOUSAND: Dynamic = Self(Union::Int(1000, DEFAULT_TAG_VALUE, ReadWrite));
|
||||||
/// A [`Dynamic`] containing the integer negative one.
|
/// A [`Dynamic`] containing the integer negative one.
|
||||||
pub const NEGATIVE_ONE: Dynamic = Self(Union::Int(-1, DEFAULT_TAG_VALUE, ReadWrite));
|
pub const NEGATIVE_ONE: Dynamic = Self(Union::Int(-1, DEFAULT_TAG_VALUE, ReadWrite));
|
||||||
/// A [`Dynamic`] containing `0.0`.
|
/// A [`Dynamic`] containing `0.0`.
|
||||||
@ -870,7 +876,25 @@ impl Dynamic {
|
|||||||
DEFAULT_TAG_VALUE,
|
DEFAULT_TAG_VALUE,
|
||||||
ReadWrite,
|
ReadWrite,
|
||||||
));
|
));
|
||||||
/// A [`Dynamic`] containing the `-1.0`.
|
/// A [`Dynamic`] containing `100.0`.
|
||||||
|
///
|
||||||
|
/// Not available under `no_float`.
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
pub const FLOAT_HUNDRED: Dynamic = Self(Union::Float(
|
||||||
|
FloatWrapper::new_const(100.0),
|
||||||
|
DEFAULT_TAG_VALUE,
|
||||||
|
ReadWrite,
|
||||||
|
));
|
||||||
|
/// A [`Dynamic`] containing `1000.0`.
|
||||||
|
///
|
||||||
|
/// Not available under `no_float`.
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
pub const FLOAT_THOUSAND: Dynamic = Self(Union::Float(
|
||||||
|
FloatWrapper::new_const(1000.0),
|
||||||
|
DEFAULT_TAG_VALUE,
|
||||||
|
ReadWrite,
|
||||||
|
));
|
||||||
|
/// A [`Dynamic`] containing `-1.0`.
|
||||||
///
|
///
|
||||||
/// Not available under `no_float`.
|
/// Not available under `no_float`.
|
||||||
#[cfg(not(feature = "no_float"))]
|
#[cfg(not(feature = "no_float"))]
|
||||||
@ -879,6 +903,42 @@ impl Dynamic {
|
|||||||
DEFAULT_TAG_VALUE,
|
DEFAULT_TAG_VALUE,
|
||||||
ReadWrite,
|
ReadWrite,
|
||||||
));
|
));
|
||||||
|
/// A [`Dynamic`] containing π.
|
||||||
|
///
|
||||||
|
/// Not available under `no_float`.
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
pub const FLOAT_PI: Dynamic = Self(Union::Float(
|
||||||
|
#[cfg(not(feature = "f32_float"))]
|
||||||
|
FloatWrapper::new_const(std::f64::consts::PI),
|
||||||
|
#[cfg(feature = "f32_float")]
|
||||||
|
FloatWrapper::new_const(std::f32::consts::PI),
|
||||||
|
DEFAULT_TAG_VALUE,
|
||||||
|
ReadWrite,
|
||||||
|
));
|
||||||
|
/// A [`Dynamic`] containing π/2.
|
||||||
|
///
|
||||||
|
/// Not available under `no_float`.
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
pub const FLOAT_HALF_PI: Dynamic = Self(Union::Float(
|
||||||
|
#[cfg(not(feature = "f32_float"))]
|
||||||
|
FloatWrapper::new_const(std::f64::consts::PI / 2.0),
|
||||||
|
#[cfg(feature = "f32_float")]
|
||||||
|
FloatWrapper::new_const(std::f32::consts::PI / 2.0),
|
||||||
|
DEFAULT_TAG_VALUE,
|
||||||
|
ReadWrite,
|
||||||
|
));
|
||||||
|
/// A [`Dynamic`] containing 2π.
|
||||||
|
///
|
||||||
|
/// Not available under `no_float`.
|
||||||
|
#[cfg(not(feature = "no_float"))]
|
||||||
|
pub const FLOAT_TWO_PI: Dynamic = Self(Union::Float(
|
||||||
|
#[cfg(not(feature = "f32_float"))]
|
||||||
|
FloatWrapper::new_const(2.0 * std::f64::consts::PI),
|
||||||
|
#[cfg(feature = "f32_float")]
|
||||||
|
FloatWrapper::new_const(2.0 * std::f32::consts::PI),
|
||||||
|
DEFAULT_TAG_VALUE,
|
||||||
|
ReadWrite,
|
||||||
|
));
|
||||||
|
|
||||||
/// Get the [`AccessMode`] for this [`Dynamic`].
|
/// Get the [`AccessMode`] for this [`Dynamic`].
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
Loading…
Reference in New Issue
Block a user