add missing num-traits supertraits to FixedOptionalFeatures
This commit is contained in:
parent
53ea435929
commit
fd066b1c97
|
@ -78,6 +78,12 @@ The conversions supported cover the following cases.
|
|||
|
||||
## What’s new
|
||||
|
||||
### Version 1.4.1 news (unreleased)
|
||||
|
||||
* For the experimental feature [`num-traits`][feat-exp-1-4], some
|
||||
missing supertraits were added to
|
||||
[`FixedOptionalFeatures`][tfof-1-4].
|
||||
|
||||
### Version 1.4.0 news (2020-10-22)
|
||||
|
||||
* The following methods were added to all fixed-point types, to the
|
||||
|
@ -117,6 +123,7 @@ The conversions supported cover the following cases.
|
|||
[nt-0-2-tp]: https://docs.rs/num-traits/^0.2/num_traits/cast/trait.ToPrimitive.html
|
||||
[nt-0-2-unsigned]: https://docs.rs/num-traits/^0.2/num_traits/sign/trait.Unsigned.html
|
||||
[tf-1-4]: https://docs.rs/fixed/~1.4/fixed/traits/trait.Fixed.html
|
||||
[tfof-1-4]: https://docs.rs/fixed/~1.4/fixed/traits/trait.FixedOptionalFeatures.html
|
||||
[w-1-4]: https://docs.rs/fixed/~1.4/fixed/struct.Wrapping.html
|
||||
|
||||
### Version 1.3.0 news (2020-10-15)
|
||||
|
|
|
@ -5,6 +5,13 @@ modification, are permitted in any medium without royalty provided the
|
|||
copyright notice and this notice are preserved. This file is offered
|
||||
as-is, without any warranty. -->
|
||||
|
||||
Version 1.4.1 (unreleased)
|
||||
==========================
|
||||
|
||||
* For the experimental feature [`num-traits`][feat-exp-1-4], some
|
||||
missing supertraits were added to
|
||||
[`FixedOptionalFeatures`][tfof-1-4].
|
||||
|
||||
Version 1.4.0 (2020-10-22)
|
||||
==========================
|
||||
|
||||
|
@ -45,6 +52,7 @@ Version 1.4.0 (2020-10-22)
|
|||
[nt-0-2-tp]: https://docs.rs/num-traits/^0.2/num_traits/cast/trait.ToPrimitive.html
|
||||
[nt-0-2-unsigned]: https://docs.rs/num-traits/^0.2/num_traits/sign/trait.Unsigned.html
|
||||
[tf-1-4]: https://docs.rs/fixed/~1.4/fixed/traits/trait.Fixed.html
|
||||
[tfof-1-4]: https://docs.rs/fixed/~1.4/fixed/traits/trait.FixedOptionalFeatures.html
|
||||
[w-1-4]: https://docs.rs/fixed/~1.4/fixed/struct.Wrapping.html
|
||||
|
||||
Version 1.3.0 (2020-10-15)
|
||||
|
|
|
@ -129,10 +129,7 @@ macro_rules! impl_traits {
|
|||
}
|
||||
}
|
||||
|
||||
impl<Frac: $LeEqU> Inv for $Fixed<Frac>
|
||||
where
|
||||
Frac: IsLessOrEqual<$OneMaxFrac, Output = True>,
|
||||
{
|
||||
impl<Frac: $LeEqU> Inv for $Fixed<Frac> {
|
||||
type Output = Self;
|
||||
#[inline]
|
||||
fn inv(self) -> Self::Output {
|
||||
|
|
|
@ -39,12 +39,15 @@ use half::{bf16, f16};
|
|||
#[cfg(feature = "num-traits")]
|
||||
use num_traits::{
|
||||
bounds::Bounded,
|
||||
cast::{FromPrimitive, ToPrimitive},
|
||||
float::FloatConst,
|
||||
identities::Zero,
|
||||
ops::{
|
||||
checked::{
|
||||
CheckedAdd, CheckedDiv, CheckedMul, CheckedNeg, CheckedRem, CheckedShl, CheckedShr,
|
||||
CheckedSub,
|
||||
},
|
||||
inv::Inv,
|
||||
saturating::{SaturatingAdd, SaturatingMul, SaturatingSub},
|
||||
wrapping::{WrappingAdd, WrappingMul, WrappingNeg, WrappingShl, WrappingShr, WrappingSub},
|
||||
},
|
||||
|
@ -76,12 +79,13 @@ macro_rules! comment_features {
|
|||
$comment;
|
||||
pub trait FixedOptionalFeatures
|
||||
where
|
||||
Self: Bounded + Zero,
|
||||
Self: Zero + Bounded + Inv,
|
||||
Self: CheckedAdd + CheckedSub + CheckedNeg + CheckedMul,
|
||||
Self: CheckedDiv + CheckedRem + CheckedShl + CheckedShr,
|
||||
Self: SaturatingAdd + SaturatingSub + SaturatingMul,
|
||||
Self: WrappingAdd + WrappingSub + WrappingNeg + WrappingMul,
|
||||
Self: WrappingShl + WrappingShr,
|
||||
Self: ToPrimitive + FromPrimitive + FloatConst,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -92,12 +96,13 @@ macro_rules! comment_features {
|
|||
$comment;
|
||||
pub trait FixedOptionalFeatures
|
||||
where
|
||||
Self: Bounded + Zero,
|
||||
Self: Zero + Bounded + Inv,
|
||||
Self: CheckedAdd + CheckedSub + CheckedNeg + CheckedMul,
|
||||
Self: CheckedDiv + CheckedRem + CheckedShl + CheckedShr,
|
||||
Self: SaturatingAdd + SaturatingSub + SaturatingMul,
|
||||
Self: WrappingAdd + WrappingSub + WrappingNeg + WrappingMul,
|
||||
Self: WrappingShl + WrappingShr,
|
||||
Self: ToPrimitive + FromPrimitive + FloatConst,
|
||||
Self: Serialize + for<'de> Deserialize<'de>,
|
||||
{
|
||||
}
|
||||
|
@ -127,12 +132,13 @@ macro_rules! comment_features {
|
|||
pub trait FixedOptionalFeatures
|
||||
where
|
||||
Self: PartialOrd<f16> + PartialOrd<bf16>,
|
||||
Self: Bounded + Zero,
|
||||
Self: Zero + Bounded + Inv,
|
||||
Self: CheckedAdd + CheckedSub + CheckedNeg + CheckedMul,
|
||||
Self: CheckedDiv + CheckedRem + CheckedShl + CheckedShr,
|
||||
Self: SaturatingAdd + SaturatingSub + SaturatingMul,
|
||||
Self: WrappingAdd + WrappingSub + WrappingNeg + WrappingMul,
|
||||
Self: WrappingShl + WrappingShr,
|
||||
Self: ToPrimitive + FromPrimitive + FloatConst,
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -144,12 +150,13 @@ macro_rules! comment_features {
|
|||
pub trait FixedOptionalFeatures
|
||||
where
|
||||
Self: PartialOrd<f16> + PartialOrd<bf16>,
|
||||
Self: Bounded + Zero,
|
||||
Self: Zero + Bounded + Inv,
|
||||
Self: CheckedAdd + CheckedSub + CheckedNeg + CheckedMul,
|
||||
Self: CheckedDiv + CheckedRem + CheckedShl + CheckedShr,
|
||||
Self: SaturatingAdd + SaturatingSub + SaturatingMul,
|
||||
Self: WrappingAdd + WrappingSub + WrappingNeg + WrappingMul,
|
||||
Self: WrappingShl + WrappingShr,
|
||||
Self: ToPrimitive + FromPrimitive + FloatConst,
|
||||
Self: Serialize + for<'de> Deserialize<'de>,
|
||||
{
|
||||
}
|
||||
|
@ -167,16 +174,32 @@ depending on the crate’s [optional features].
|
|||
supertraits of [`Fixed`].
|
||||
2. If the `num-traits` experimental feature is enabled, the following
|
||||
are supertraits of [`Fixed`]:
|
||||
* [`Bounded`], [`Zero`] (but *not* [`One`] because not all
|
||||
fixed-point numbers can represent the value 1)
|
||||
* [`Zero`]
|
||||
* [`Bounded`]
|
||||
* [`Inv`]
|
||||
* [`CheckedAdd`], [`CheckedSub`], [`CheckedNeg`],
|
||||
[`CheckedMul`], [`CheckedDiv`], [`CheckedRem`],
|
||||
[`CheckedShl`], [`CheckedShr`]
|
||||
* [`SaturatingAdd`], [`SaturatingSub`], [`SaturatingMul`]
|
||||
* [`WrappingAdd`], [`WrappingSub`], [`WrappingNeg`],
|
||||
[`WrappingMul`], [`WrappingShl`], [`WrappingShr`]
|
||||
* [`FloatConst`]
|
||||
* [`ToPrimitive`], [`FromPrimitive`]
|
||||
* [`FloatConst`]
|
||||
|
||||
The following are *not* supertraits of [`Fixed`], even though they
|
||||
are implemented for fixed-point numbers where applicable:
|
||||
* [`One`] because not all fixed-point numbers can represent the
|
||||
value 1
|
||||
* [`Num`] because it has [`One`] as a supertrait
|
||||
* [`MulAdd`], [`MulAddAssign`] because
|
||||
<code>[MulAdd][`MulAdd`]::[mul_add][`MulAdd::mul_add`]</code>
|
||||
conflicts with
|
||||
<code>[Fixed][`Fixed`]::[mul_add][`Fixed::mul_add`]</code>
|
||||
|
||||
Similarly, [`Signed`] and [`Unsigned`] are *not* supertraits of
|
||||
[`FixedSigned`] and [`FixedUnsigned`] because they have [`Num`] as
|
||||
a supertrait.
|
||||
|
||||
3. If the `serde` feature is enabled, [`Serialize`] and
|
||||
[`Deserialize`] are supertraits of [`Fixed`].
|
||||
|
||||
|
@ -190,16 +213,26 @@ depending on the crate’s [optional features].
|
|||
[`CheckedShr`]: https://docs.rs/num-traits/^0.2/num_traits/ops/checked/trait.CheckedShr.html
|
||||
[`CheckedSub`]: https://docs.rs/num-traits/^0.2/num_traits/ops/checked/trait.CheckedSub.html
|
||||
[`Deserialize`]: https://docs.rs/serde/^1/serde/de/trait.Deserialize.html
|
||||
[`Fixed::mul_add`]: trait.Fixed.html#tymethod.mul_add
|
||||
[`FixedSigned`]: trait.FixedSigned.html
|
||||
[`FixedUnsigned`]: trait.FixedUnsigned.html
|
||||
[`Fixed`]: trait.Fixed.html
|
||||
[`FloatConst`]: https://docs.rs/num-traits/^0.2/num_traits/float/trait.FloatConst.html
|
||||
[`FromPrimitive`]: https://docs.rs/num-traits/^0.2/num_traits/cast/trait.ToPrimitive.html
|
||||
[`Inv`]: https://docs.rs/num-traits/^0.2/num_traits/ops/inv/trait.Inv.html
|
||||
[`MulAdd::mul_add`]: https://docs.rs/num-traits/^0.2/num_traits/ops/mul_add/trait.MulAdd.html#tymethod.mul_add
|
||||
[`MulAddAssign`]: https://docs.rs/num-traits/^0.2/num_traits/ops/mul_add/trait.MulAddAssign.html
|
||||
[`MulAdd`]: https://docs.rs/num-traits/^0.2/num_traits/ops/mul_add/trait.MulAdd.html
|
||||
[`Num`]: https://docs.rs/num-traits/^0.2/num_traits/trait.Num.html
|
||||
[`One`]: https://docs.rs/num-traits/^0.2/num_traits/identities/trait.One.html
|
||||
[`PartialOrd`]: https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html
|
||||
[`SaturatingAdd`]: https://docs.rs/num-traits/^0.2/num_traits/ops/saturating/trait.SaturatingAdd.html
|
||||
[`SaturatingMul`]: https://docs.rs/num-traits/^0.2/num_traits/ops/saturating/trait.SaturatingMul.html
|
||||
[`SaturatingSub`]: https://docs.rs/num-traits/^0.2/num_traits/ops/saturating/trait.SaturatingSub.html
|
||||
[`Serialize`]: https://docs.rs/serde/^1/serde/ser/trait.Serialize.html
|
||||
[`Signed`]: https://docs.rs/num-traits/^0.2/num_traits/sign/trait.Signed.html
|
||||
[`ToPrimitive`]: https://docs.rs/num-traits/^0.2/num_traits/cast/trait.FromPrimitive.html
|
||||
[`Unsigned`]: https://docs.rs/num-traits/^0.2/num_traits/sign/trait.Unsigned.html
|
||||
[`WrappingAdd`]: https://docs.rs/num-traits/^0.2/num_traits/ops/wrapping/trait.WrappingAdd.html
|
||||
[`WrappingMul`]: https://docs.rs/num-traits/^0.2/num_traits/ops/wrapping/trait.WrappingMul.html
|
||||
[`WrappingNeg`]: https://docs.rs/num-traits/^0.2/num_traits/ops/wrapping/trait.WrappingNeg.html
|
||||
|
|
Loading…
Reference in New Issue