move display/debug funtionality back to `std`-gated macro

This commit is contained in:
David Palm 2018-08-10 19:45:11 +02:00
parent 33567263fa
commit 4336907eac
1 changed files with 35 additions and 19 deletions

View File

@ -1183,6 +1183,39 @@ macro_rules! construct_uint {
}
}
impl_std_for_uint!($name, $n_words);
impl_heapsize_for_uint!($name);
// `$n_words * 8` because macro expects bytes and
// uints use 64 bit (8 byte) words
impl_quickcheck_arbitrary_for_uint!($name, ($n_words * 8));
);
}
#[cfg(feature="std")]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_std_for_uint_internals {
($name: ident, $n_words: tt) => {
/// Convert to hex string.
#[deprecated(note = "Use LowerHex instead.")]
pub fn to_hex(&self) -> String {
format!("{:x}", self)
}
}
}
#[cfg(not(feature="std"))]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_std_for_uint_internals {
($name: ident, $n_words: tt) => {}
}
#[cfg(feature="std")]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_std_for_uint {
($name: ident, $n_words: tt) => {
impl ::core::fmt::Debug for $name {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Display::fmt(self, f)
@ -1264,34 +1297,17 @@ macro_rules! construct_uint {
s.parse().unwrap()
}
}
impl_heapsize_for_uint!($name);
// `$n_words * 8` because macro expects bytes and
// uints use 64 bit (8 byte) words
impl_quickcheck_arbitrary_for_uint!($name, ($n_words * 8));
);
}
#[cfg(feature="std")]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_std_for_uint_internals {
($name: ident, $n_words: tt) => {
/// Convert to hex string.
#[deprecated(note = "Use LowerHex instead.")]
pub fn to_hex(&self) -> String {
format!("{:x}", self)
}
}
}
#[cfg(not(feature="std"))]
#[macro_export]
#[doc(hidden)]
macro_rules! impl_std_for_uint_internals {
macro_rules! impl_std_for_uint {
($name: ident, $n_words: tt) => {}
}
#[cfg(feature="heapsizeof")]
#[macro_export]
#[doc(hidden)]