macros.rs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // not all are used in all features configurations
  2. #![allow(unused)]
  3. /// Forward a method to an inherent method or a base trait method.
  4. macro_rules! forward {
  5. ($( Self :: $method:ident ( self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*)
  6. => {$(
  7. #[inline]
  8. fn $method(self $( , $arg : $ty )* ) -> $ret {
  9. Self::$method(self $( , $arg )* )
  10. }
  11. )*};
  12. ($( $base:ident :: $method:ident ( self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*)
  13. => {$(
  14. #[inline]
  15. fn $method(self $( , $arg : $ty )* ) -> $ret {
  16. <Self as $base>::$method(self $( , $arg )* )
  17. }
  18. )*};
  19. ($( $base:ident :: $method:ident ( $( $arg:ident : $ty:ty ),* ) -> $ret:ty ; )*)
  20. => {$(
  21. #[inline]
  22. fn $method( $( $arg : $ty ),* ) -> $ret {
  23. <Self as $base>::$method( $( $arg ),* )
  24. }
  25. )*}
  26. }
  27. macro_rules! constant {
  28. ($( $method:ident () -> $ret:expr ; )*)
  29. => {$(
  30. #[inline]
  31. fn $method() -> Self {
  32. $ret
  33. }
  34. )*};
  35. }