more cleanup

This commit is contained in:
nora 2022-02-26 23:24:08 +01:00
parent 6d944e1265
commit de027d9f5a
9 changed files with 46 additions and 14 deletions

View file

@ -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 {
() => {