remove deprecated items

This commit is contained in:
Trevor Spiteri 2020-05-01 18:28:17 +02:00
parent bf239e9c76
commit 879861b875
7 changed files with 21 additions and 384 deletions

View File

@ -74,17 +74,17 @@ The conversions supported cover the following cases.
## Whats new
### Version 0.5.6 news (2020-05-01)
### Version 1.0.0 news (unreleased)
**This release is meant to be the last release before version 1.0.0:**
The plan is that the only differences between 0.5.6 and 1.0.0 will be
dependency updates and the removal of deprecated items.
* All deprecated items were removed.
### Version 0.5.6 news (2020-05-01)
Other news in this release:
* The following method were added to signed fixed-point types and to
the [`FixedSigned`][tfs-0-5-6] trait:
* [`checked_signum`][f-csig-0-5-6],
* [`checked_signum`][f-csig-0-5-6],
[`saturating_signum`][f-ssig-0-5-6],
[`wrapping_signum`][f-wsig-0-5-6],
[`overflowing_signum`][f-osig-0-5-6]

View File

@ -5,12 +5,17 @@ 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.0.0 (unreleased)
==========================
* All deprecated items were removed.
Version 0.5.6 (2020-05-01)
==========================
* The following method were added to signed fixed-point types and to
the `FixedSigned` trait:
* `checked_signum`, `saturating_signum`, `wrapping_signum`,
* `checked_signum`, `saturating_signum`, `wrapping_signum`,
`overflowing_signum`
* The `LossyFrom` and `LossyInto` traits were added to the prelude.
* Casts deprecated in version 0.3.1 of the *az* crate were marked as

View File

@ -18,14 +18,11 @@ use crate::{
FixedI128, FixedI16, FixedI32, FixedI64, FixedI8, FixedU128, FixedU16, FixedU32, FixedU64,
FixedU8,
};
#[allow(deprecated)]
use az::StaticCast;
use az::{Cast, CheckedCast, OverflowingCast, SaturatingCast, WrappingCast};
use core::mem;
#[cfg(feature = "f16")]
use half::{bf16, f16};
macro_rules! run_time {
macro_rules! cast {
($Src:ident($LeEqUSrc:ident); $Dst:ident($LeEqUDst:ident)) => {
impl<FracSrc: $LeEqUSrc, FracDst: $LeEqUDst> Cast<$Dst<FracDst>> for $Src<FracSrc> {
#[inline]
@ -142,269 +139,38 @@ macro_rules! run_time {
};
}
macro_rules! compile_time {
(
impl<$FracSrc:ident: $LeEqUSrc:ident, $FracDst:ident: $LeEqUDst:ident> StaticCast<$Dst:ty>
for $Src:ty
{
$cond:expr
}
) => {
#[deprecated(since = "0.5.6", note = "deprecated in az crate")]
#[allow(deprecated)]
/// <div class='stability'><div class='stab deprecated'>Deprecated since 0.5.6:
/// <p>deprecated in az crate since 0.3.1; use case is unclear</p></div></div>
impl<$FracSrc: $LeEqUSrc, $FracDst: $LeEqUDst> StaticCast<$Dst> for $Src {
#[inline]
fn static_cast(self) -> Option<$Dst> {
if $cond {
Some(az::cast(self))
} else {
None
}
}
}
};
(impl<$Frac:ident: $LeEqU:ident> StaticCast<$Dst:ty> for $Src:ty { $cond:expr }) => {
#[deprecated(since = "0.5.6", note = "deprecated in az crate")]
#[allow(deprecated)]
/// <div class='stability'><div class='stab deprecated'>Deprecated since 0.5.6:
/// <p>deprecated in az crate since 0.3.1; use case is unclear</p></div></div>
impl<$Frac: $LeEqU> StaticCast<$Dst> for $Src {
#[inline]
fn static_cast(self) -> Option<$Dst> {
if $cond {
Some(az::cast(self))
} else {
None
}
}
}
};
($SrcI:ident, $SrcU:ident($LeEqUSrc:ident); $DstI:ident, $DstU:ident($LeEqUDst:ident)) => {
compile_time! {
impl<FracSrc: $LeEqUSrc, FracDst: $LeEqUDst> StaticCast<$DstI<FracDst>>
for $SrcI<FracSrc>
{
<$DstI<FracDst>>::INT_NBITS >= <$SrcI<FracSrc>>::INT_NBITS
}
}
compile_time! {
impl<FracSrc: $LeEqUSrc, FracDst: $LeEqUDst> StaticCast<$DstU<FracDst>>
for $SrcI<FracSrc>
{
false
}
}
compile_time! {
impl<FracSrc: $LeEqUSrc, FracDst: $LeEqUDst> StaticCast<$DstI<FracDst>>
for $SrcU<FracSrc>
{
<$DstI<FracDst>>::INT_NBITS > <$SrcU<FracSrc>>::INT_NBITS
}
}
compile_time! {
impl<FracSrc: $LeEqUSrc, FracDst: $LeEqUDst> StaticCast<$DstU<FracDst>>
for $SrcU<FracSrc>
{
<$DstU<FracDst>>::INT_NBITS >= <$SrcU<FracSrc>>::INT_NBITS
}
}
};
($FixedI:ident, $FixedU:ident($LeEqU:ident); int $DstI:ident, $DstU:ident) => {
compile_time! {
impl<Frac: $LeEqU> StaticCast<$DstI> for $FixedI<Frac> {
8 * mem::size_of::<$DstI>() as u32 >= <$FixedI<Frac>>::INT_NBITS
}
}
compile_time! {
impl<Frac: $LeEqU> StaticCast<$DstI> for $FixedU<Frac> {
8 * mem::size_of::<$DstI>() as u32 > <$FixedU<Frac>>::INT_NBITS
}
}
compile_time! {
impl<Frac: $LeEqU> StaticCast<$DstU> for $FixedI<Frac> {
false
}
}
compile_time! {
impl<Frac: $LeEqU> StaticCast<$DstU> for $FixedU<Frac> {
8 * mem::size_of::<$DstU>() as u32 >= <$FixedU<Frac>>::INT_NBITS
}
}
};
(int $SrcI:ident, $SrcU:ident; $FixedI:ident, $FixedU:ident($LeEqU:ident)) => {
compile_time! {
impl<Frac: $LeEqU> StaticCast<$FixedI<Frac>> for $SrcI {
<$FixedI<Frac>>::INT_NBITS >= 8 * mem::size_of::<$SrcI>() as u32
}
}
compile_time! {
impl<Frac: $LeEqU> StaticCast<$FixedU<Frac>> for $SrcI {
false
}
}
compile_time! {
impl<Frac: $LeEqU> StaticCast<$FixedI<Frac>> for $SrcU {
<$FixedI<Frac>>::INT_NBITS > 8 * mem::size_of::<$SrcU>() as u32
}
}
compile_time! {
impl<Frac: $LeEqU> StaticCast<$FixedU<Frac>> for $SrcU {
<$FixedU<Frac>>::INT_NBITS >= 8 * mem::size_of::<$SrcU>() as u32
}
}
};
($Fixed:ident($LeEqU:ident); float $Dst:ident) => {
compile_time! {
impl<Frac: $LeEqU> StaticCast<$Dst> for $Fixed<Frac> {
true
}
}
};
(float $Src:ident; $Fixed:ident($LeEqU:ident)) => {
compile_time! {
impl<Frac: $LeEqU> StaticCast<$Fixed<Frac>> for $Src {
false
}
}
};
}
macro_rules! run_time_num {
macro_rules! cast_num {
($Src:ident($LeEqUSrc:ident); $($Dst:ident($LeEqUDst:ident),)*) => { $(
run_time! { $Src($LeEqUSrc); $Dst($LeEqUDst) }
cast! { $Src($LeEqUSrc); $Dst($LeEqUDst) }
)* };
($Fixed:ident($LeEqU:ident); $($Num:ident,)*) => { $(
run_time! { $Fixed($LeEqU); $Num }
run_time! { $Num; $Fixed($LeEqU) }
cast! { $Fixed($LeEqU); $Num }
cast! { $Num; $Fixed($LeEqU) }
)* };
($($Fixed:ident($LeEqU:ident),)*) => { $(
run_time_num! {
cast_num! {
$Fixed($LeEqU);
FixedI8(LeEqU8), FixedI16(LeEqU16), FixedI32(LeEqU32), FixedI64(LeEqU64),
FixedI128(LeEqU128),
FixedU8(LeEqU8), FixedU16(LeEqU16), FixedU32(LeEqU32), FixedU64(LeEqU64),
FixedU128(LeEqU128),
}
run_time! { bool; $Fixed($LeEqU) }
run_time_num! {
cast! { bool; $Fixed($LeEqU) }
cast_num! {
$Fixed($LeEqU);
i8, i16, i32, i64, i128, isize,
u8, u16, u32, u64, u128, usize,
f32, f64,
}
#[cfg(feature = "f16")]
run_time_num! {
cast_num! {
$Fixed($LeEqU);
f16, bf16,
}
)* };
}
run_time_num! {
FixedI8(LeEqU8), FixedI16(LeEqU16), FixedI32(LeEqU32), FixedI64(LeEqU64), FixedI128(LeEqU128),
FixedU8(LeEqU8), FixedU16(LeEqU16), FixedU32(LeEqU32), FixedU64(LeEqU64), FixedU128(LeEqU128),
}
macro_rules! compile_time_fixed {
(
$SrcI:ident, $SrcU:ident($LeEqUSrc:ident); $(($DstI:ident, $DstU:ident($LeEqUDst:ident)),)*
) => { $(
compile_time! { $SrcI, $SrcU($LeEqUSrc); $DstI, $DstU($LeEqUDst) }
)* };
($($FixedI:ident, $FixedU:ident($LeEqU:ident),)*) => { $(
compile_time_fixed! {
$FixedI, $FixedU($LeEqU);
(FixedI8, FixedU8(LeEqU8)),
(FixedI16, FixedU16(LeEqU16)),
(FixedI32, FixedU32(LeEqU32)),
(FixedI64, FixedU64(LeEqU64)),
(FixedI128, FixedU128(LeEqU128)),
}
)* };
}
compile_time_fixed! {
FixedI8, FixedU8(LeEqU8),
FixedI16, FixedU16(LeEqU16),
FixedI32, FixedU32(LeEqU32),
FixedI64, FixedU64(LeEqU64),
FixedI128, FixedU128(LeEqU128),
}
macro_rules! compile_time_int {
($FixedI:ident, $FixedU:ident($LeEqU:ident); $(($IntI:ident, $IntU:ident),)*) => { $(
compile_time! { $FixedI, $FixedU($LeEqU); int $IntI, $IntU }
compile_time! { int $IntI, $IntU; $FixedI, $FixedU($LeEqU) }
)* };
($($FixedI:ident, $FixedU:ident($LeEqU:ident),)*) => { $(
compile_time! {
impl<Frac: $LeEqU> StaticCast<$FixedI<Frac>> for bool {
<$FixedI<Frac>>::INT_NBITS > 1
}
}
compile_time! {
impl<Frac: $LeEqU> StaticCast<$FixedU<Frac>> for bool {
<$FixedU<Frac>>::INT_NBITS >= 1
}
}
compile_time_int! {
$FixedI, $FixedU($LeEqU);
(i8, u8),
(i16, u16),
(i32, u32),
(i64, u64),
(i128, u128),
(isize, usize),
}
)* };
}
compile_time_int! {
FixedI8, FixedU8(LeEqU8),
FixedI16, FixedU16(LeEqU16),
FixedI32, FixedU32(LeEqU32),
FixedI64, FixedU64(LeEqU64),
FixedI128, FixedU128(LeEqU128),
}
macro_rules! compile_time_float {
($Fixed:ident($LeEqU:ident); $($Float:ident,)*) => { $(
compile_time! { $Fixed($LeEqU); float $Float }
compile_time! { float $Float; $Fixed($LeEqU) }
)* };
($($Fixed:ident($LeEqU:ident),)*) => { $(
compile_time_float! {
$Fixed($LeEqU);
f32, f64,
}
#[cfg(feature = "f16")]
compile_time_float! {
$Fixed($LeEqU);
f16, bf16,
}
)* };
}
compile_time_float! {
cast_num! {
FixedI8(LeEqU8), FixedI16(LeEqU16), FixedI32(LeEqU32), FixedI64(LeEqU64), FixedI128(LeEqU128),
FixedU8(LeEqU8), FixedU16(LeEqU16), FixedU32(LeEqU32), FixedU64(LeEqU64), FixedU128(LeEqU128),
}

View File

@ -1250,42 +1250,6 @@ assert_eq!(Fix::from_num(-7.5).overflowing_rem_euclid_int(20), (Fix::from_num(-3
}
}
}
/// Returns the number of integer bits.
#[inline]
#[deprecated(since = "0.5.5", note = "use `INT_NBITS` instead")]
pub fn int_nbits() -> u32 {
Self::INT_NBITS
}
/// Returns the number of fractional bits.
#[inline]
#[deprecated(since = "0.5.5", note = "use `FRAC_NBITS` instead")]
pub fn frac_nbits() -> u32 {
Self::FRAC_NBITS
}
/// Remainder for division by an integer.
///
/// # Panics
///
/// Panics if the divisor is zero.
#[inline]
#[deprecated(since = "0.5.3", note = "cannot overflow, use `%` or `Rem::rem` instead")]
pub fn wrapping_rem_int(self, rhs: $Inner) -> $Fixed<Frac> {
self % rhs
}
/// Remainder for division by an integer.
///
/// # Panics
///
/// Panics if the divisor is zero.
#[inline]
#[deprecated(since = "0.5.3", note = "cannot overflow, use `%` or `Rem::rem` instead")]
pub fn overflowing_rem_int(self, rhs: $Inner) -> ($Fixed<Frac>, bool) {
(self % rhs, false)
}
}
};
}

View File

@ -1423,20 +1423,6 @@ assert_eq!(Fix::MIN.overflowing_abs(), (Fix::MIN, true));
let not_mask = (cond as $Inner).wrapping_sub(1);
Self::from_bits((self.to_bits() & !not_mask) | (otherwise.to_bits() & not_mask))
}
/// Returns the smallest value that can be represented.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `MIN`")]
pub const fn min_value() -> $Fixed<Frac> {
Self::MIN
}
/// Returns the largest value that can be represented.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `MAX`")]
pub const fn max_value() -> $Fixed<Frac> {
Self::MAX
}
}
};
}

View File

@ -997,62 +997,6 @@ where
/// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html
/// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html
fn overflowing_shr(self, rhs: u32) -> (Self, bool);
/// Returns the smallest value that can be represented.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `MIN`")]
fn min_value() -> Self {
Self::MIN
}
/// Returns the largest value that can be represented.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `MAX`")]
fn max_value() -> Self {
Self::MAX
}
/// Returns the number of integer bits.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `INT_NBITS`")]
fn int_nbits() -> u32 {
Self::INT_NBITS
}
/// Returns the number of fractional bits.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `FRAC_NBITS`")]
fn frac_nbits() -> u32 {
Self::FRAC_NBITS
}
/// Remainder for division by an integer.
///
/// # Panics
///
/// Panics if the divisor is zero.
#[inline]
#[deprecated(
since = "0.5.3",
note = "cannot overflow, use `%` or `Rem::rem` instead"
)]
fn wrapping_rem_int(self, rhs: Self::Bits) -> Self {
self % rhs
}
/// Remainder for division by an integer.
///
/// # Panics
///
/// Panics if the divisor is zero.
#[inline]
#[deprecated(
since = "0.5.3",
note = "cannot overflow, use `%` or `Rem::rem` instead"
)]
fn overflowing_rem_int(self, rhs: Self::Bits) -> (Self, bool) {
(self % rhs, false)
}
}
/// This trait provides methods common to all signed fixed-point numbers.

View File

@ -619,34 +619,6 @@ impl<F: Fixed> Wrapping<F> {
pub fn rem_euclid_int(self, divisor: F::Bits) -> Wrapping<F> {
Wrapping(self.0.wrapping_rem_euclid_int(divisor))
}
/// Returns the smallest value that can be represented.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `MIN`")]
pub fn min_value() -> Wrapping<F> {
Self::MIN
}
/// Returns the largest value that can be represented.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `MAX`")]
pub fn max_value() -> Wrapping<F> {
Self::MAX
}
/// Returns the number of integer bits.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `INT_NBITS`")]
pub fn int_nbits() -> u32 {
Self::INT_NBITS
}
/// Returns the number of fractional bits.
#[inline]
#[deprecated(since = "0.5.5", note = "replaced by `FRAC_NBITS`")]
pub fn frac_nbits() -> u32 {
Self::FRAC_NBITS
}
}
impl<F: FixedSigned> Wrapping<F> {