Reformat macros.

This commit is contained in:
Dan Barella 2018-01-29 19:38:31 -05:00 committed by Josh Stone
parent c32cb5c65b
commit aab7098acd
1 changed files with 8 additions and 14 deletions

View File

@ -239,31 +239,25 @@ macro_rules! impl_to_primitive_float_to_float {
}
macro_rules! impl_to_primitive_float_to_signed_int {
($SrcT:ident, $DstT:ident, $slf:expr) => (
($SrcT:ident, $DstT:ident, $slf:expr) => ({
let t = $slf.trunc();
if t >= $DstT::MIN as $SrcT && t <= $DstT::MAX as $SrcT {
if t >= $DstT::min_value() as $SrcT && t <= $DstT::max_value() as $SrcT {
Some($slf as $DstT)
} else {
None
}
)
})
}
macro_rules! impl_to_primitive_float_to_unsigned_int {
($SrcT:ident, $DstT:ident, $slf:expr) => (
if size_of::<$SrcT>() <= size_of::<$DstT>() {
($SrcT:ident, $DstT:ident, $slf:expr) => ({
let t = $slf.trunc();
if t >= $DstT::min_value() as $SrcT && t <= $DstT::max_value() as $SrcT {
Some($slf as $DstT)
} else {
// Make sure the value is in range for the cast.
let n = $slf as $DstT;
let max_value: $DstT = ::std::$DstT::MAX;
if n <= max_value as $DstT {
Some($slf as $DstT)
} else {
None
}
None
}
)
})
}
macro_rules! impl_to_primitive_float {