tweaks previous commit

This commit is contained in:
Trevor Spiteri 2021-04-24 21:01:19 +02:00
parent f4a0f6bb10
commit 0c30d961d4
3 changed files with 11 additions and 11 deletions

View File

@ -93,8 +93,8 @@ The conversions supported cover the following cases.
### Version 1.9.0 news (unreleased)
* Fixed-point numbers can now be formatted as hexadecimal with [`Debug`]
similarly to primitive integers, for example with format strings `"{:x?}"`
and `"{:X?}"` for lower-case and upper-case hexadecimal.
similarly to primitive integers, for example formatting with `{:X?}` will
produce upper-case hexadecimal fixed-point numbers.
* The following method was added to all fixed-point numbers, to the
[`Fixed`][tf-1-9] trait, and to the [`Wrapping`][w-1-9] and
[`Unwrapped`][u-1-9] wrappers:

View File

@ -9,8 +9,8 @@ Version 1.9.0 (unreleased)
==========================
* Fixed-point numbers can now be formatted as hexadecimal with [`Debug`]
similarly to primitive integers, for example with format strings `"{:x?}"`
and `"{:X?}"` for lower-case and upper-case hexadecimal.
similarly to primitive integers, for example formatting with `{:X?}` will
produce upper-case hexadecimal fixed-point numbers.
* The following method was added to all fixed-point numbers, to the
[`Fixed`][tf-1-9] trait, and to the [`Wrapping`][w-1-9] and
[`Unwrapped`][u-1-9] wrappers:

View File

@ -13,6 +13,12 @@
// <https://www.apache.org/licenses/LICENSE-2.0> and
// <https://opensource.org/licenses/MIT>.
use core::{
cell::Cell,
fmt::{Debug, Formatter, Result as FmtResult, Write},
sync::atomic::{AtomicU32, Ordering},
};
// This is an ugly hack to check whether a `Formatter` has `debug_lower_hex` or
// `debug_upper_hex`.
//
@ -23,17 +29,11 @@
// under test.
//
// If something fails, `u32::MAX` is stored in `DEBUG_LOWER_HEX` to avoid
// repeating the hack dummy format.
// repeating the dummy write.
//
// A similar process is used for `is_debug_upper_hex` with a format string
// "{:X?}" used for the dummy write.
use core::{
cell::Cell,
fmt::{Debug, Formatter, Result as FmtResult, Write},
sync::atomic::{AtomicU32, Ordering},
};
// Both `DEBUG_LOWER_HEX` and `DEBUG_UPPER_HEX` are:
// * 0 for not cached
// * `u32::MAX` for error