chan: MgmtChannel,
}
-impl Deref for Conn {
- type Target = MgmtChannel;
- fn deref(&self) -> &MgmtChannel { &self.chan }
-}
-impl DerefMut for Conn {
- fn deref_mut(&mut self) -> &mut MgmtChannel { &mut self.chan }
-}
+deref_to_field_mut!{Conn, MgmtChannel, chan}
impl Conn {
#[throws(AE)]
pub game: InstanceName,
pub how: MgmtGameUpdateMode,
}
-impl Deref for ConnForGame {
- type Target = Conn;
- fn deref(&self) -> &Conn { &self.conn }
-}
-impl DerefMut for ConnForGame {
- fn deref_mut(&mut self) -> &mut Conn { &mut self.conn }
-}
+deref_to_field_mut!{ConnForGame, Conn, conn}
impl ConnForGame {
#[throws(AE)]
// ---------- Simple trait implementations ----------
-impl Deref for InstanceGuard<'_> {
- type Target = Instance;
- fn deref(&self) -> &Instance { &self.c.g }
-}
-impl DerefMut for InstanceGuard<'_> {
- fn deref_mut(&mut self) -> &mut Instance { &mut self.c.g }
-}
+deref_to_field_mut!{InstanceGuard<'_>, Instance, c.g}
impl FromStr for AccountScope {
type Err = InvalidScopedName;
pub use otter_base::misc as base_misc;
pub use base_misc::default;
+pub use crate::{deref_to_field, deref_to_field_mut};
pub use crate::from_instance_lock_error;
pub use crate::accounts::loaded_acl::{self, EffectiveACL, LoadedAcl, PermSet};
#[macro_export]
macro_rules! deref_to_field {
- {$outer:ident, $inner:ty, $field:ident} => {
+ {$outer:ty, $inner:ty, $($field:tt)*} => {
impl Deref for $outer {
type Target = $inner;
- fn deref(&self) -> &$inner { &self.$field }
+ fn deref(&self) -> &$inner { &self.$($field)* }
+ }
+ }
+}
+#[macro_export]
+macro_rules! deref_to_field_mut {
+ {$outer:ty, $inner:ty, $($field:tt)*} => {
+ deref_to_field!{$outer, $inner, $($field)*}
+ impl DerefMut for $outer {
+ fn deref_mut(&mut self) -> &mut $inner { &mut self.$($field)* }
}
}
}