-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b26c69
commit 779d63d
Showing
5 changed files
with
81 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -176,4 +176,5 @@ mod format_builder; | |
mod format_flags; | ||
mod noskip; | ||
mod not_feature_format; | ||
mod numtypes; | ||
mod skip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Utilties for defining custom numeric types. | ||
//! | ||
//! This defines primarily macros intended to be used when | ||
//! defining your own types. | ||
#![cfg(feature = "f16")] | ||
#![doc(hidden)] | ||
|
||
/// Implement the reference and op assign variants of a trait. | ||
macro_rules! op_impl { | ||
($t:ty, $trait:ident, $assign:ident, $op:ident, $op_assign:ident) => { | ||
impl $trait<&$t> for $t { | ||
type Output = <Self as $trait>::Output; | ||
|
||
#[inline(always)] | ||
fn $op(self, rhs: &Self) -> Self::Output { | ||
self.$op(*rhs) | ||
} | ||
} | ||
|
||
impl $assign for $t { | ||
#[inline(always)] | ||
fn $op_assign(&mut self, other: Self) { | ||
*self = self.$op(other); | ||
} | ||
} | ||
|
||
impl $assign<&$t> for $t { | ||
#[inline(always)] | ||
fn $op_assign(&mut self, other: &Self) { | ||
*self = self.$op(other); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
pub(crate) use op_impl; |