mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 12:45:04 +01:00
more cleanup
This commit is contained in:
parent
6d944e1265
commit
de027d9f5a
9 changed files with 46 additions and 14 deletions
|
|
@ -3,8 +3,9 @@ macro_rules! newtype_id {
|
|||
($vis:vis $name:ident) => {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
$vis struct $name(::uuid::Uuid);
|
||||
|
||||
|
||||
impl $name {
|
||||
#[must_use]
|
||||
pub fn random() -> Self {
|
||||
::rand::random()
|
||||
}
|
||||
|
|
@ -24,6 +25,32 @@ macro_rules! newtype_id {
|
|||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! newtype {
|
||||
($(#[$meta:meta])* $vis:vis $name:ident: $ty:ty) => {
|
||||
$(#[$meta])*
|
||||
$vis struct $name($ty);
|
||||
|
||||
impl $name {
|
||||
pub fn new(inner: $ty) -> Self {
|
||||
Self(inner)
|
||||
}
|
||||
|
||||
pub fn into_inner(self) -> $ty {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for $name {
|
||||
type Target = $ty;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! amqp_todo {
|
||||
() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue