cido-macros 0.2.0

Macros for generating code that enables easier interfacing with cido
Documentation
use std::ops::{Deref, DerefMut};

use quote::ToTokens;

#[derive(Clone, Default, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[repr(transparent)]
pub struct Dbg<T>(pub T);

impl<T> Deref for Dbg<T> {
  type Target = T;
  fn deref(&self) -> &Self::Target {
    &self.0
  }
}

impl<T> DerefMut for Dbg<T> {
  fn deref_mut(&mut self) -> &mut Self::Target {
    &mut self.0
  }
}

impl<T> AsRef<T> for Dbg<T> {
  fn as_ref(&self) -> &T {
    &self.0
  }
}

impl<T> AsMut<T> for Dbg<T> {
  fn as_mut(&mut self) -> &mut T {
    &mut self.0
  }
}

impl<T: ToTokens> core::fmt::Debug for Dbg<T> {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    core::fmt::Display::fmt(&self.0.to_token_stream(), f)
  }
}

impl<T: core::fmt::Display> core::fmt::Display for Dbg<T> {
  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
    self.0.fmt(f)
  }
}

impl<T: ToTokens> ToTokens for Dbg<T> {
  fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
    self.0.to_tokens(tokens);
  }
}