[][src]Macro gba_hal::newtype

macro_rules! newtype {
    ($(#[$attr:meta])* $new_name:ident, $v:vis $old_name:ty) => { ... };
    ($(#[$attr:meta])* $new_name:ident, $v:vis $old_name:ty, no frills) => { ... };
}

Assists in defining a newtype wrapper over some base type.

Note that rustdoc and derives are all the "meta" stuff, so you can write all of your docs and derives in front of your newtype in the same way you would for a normal struct. Then the inner type to be wrapped it name.

The macro assumes that you'll be using it to wrap numeric types and that it's safe to have a 0 value, so it automatically provides a const fn method for new that just wraps 0. Also, it derives Debug, Clone, Copy, Default, PartialEq, and Eq. If all this is not desired you can add , no frills to the invocation.

use gba_hal::newtype;

newtype! {
  /// Records a particular key press combination.
  KeyInput, u16
}
newtype! {
  /// You can't derive most stuff above array size 32, so we add
  /// the `, no frills` modifier to this one.
  BigArray, [u8; 200], no frills
}