Macro breadthread::key_type [−][src]
macro_rules! key_type {
($(#[$meta : meta]) * $vis : vis struct $tyname : ident($foreign : ident) :
[$traitname : ident, $value : expr] ;) => { ... };
}
Expand description
Create a type that internally wraps around Key
.
Example
use breadthread::Key;
use std::num::NonZeroUsize;
pub struct ForeignPointerType { no_data: [u8; 0] }
breadthread::key_type! {
/// Foobar.
pub struct MyType(ForeignPointerType) : [ForeignType, 0x1337];
}
let key = MyType::from_raw(NonZeroUsize::new(0x12).unwrap());
assert_eq!(key.into_raw(), NonZeroUsize::new(0x12).unwrap());
let _inner_key: Key<ForeignType> = key.into_key();
assert_eq!(key.identifier(), 0x1337);
Note
The new type already derives Debug
, Copy
, Clone
, PartialOrd
, Ord
, PartialEq
, Eq
,
and Hash
. Deriving these yourself will likely result in an error.