From: Ian Jackson Date: Wed, 4 May 2022 20:40:19 +0000 (+0100) Subject: Switch to deriving Deref X-Git-Tag: otter-1.1.0~290 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=c4ba8e732b67d97032560b00e32ff62eeddb577f;p=otter.git Switch to deriving Deref Signed-off-by: Ian Jackson --- diff --git a/cli/clisupport.rs b/cli/clisupport.rs index 67d1ec85..fda18f10 100644 --- a/cli/clisupport.rs +++ b/cli/clisupport.rs @@ -295,12 +295,11 @@ impl String { fn leak(self) -> &'static str { Box::::leak(self.into()) } } +#[derive(Deref,DerefMut)] pub struct Conn { pub chan: ClientMgmtChannel, } -deref_to_field_mut!{Conn, MgmtChannel, chan} - impl Conn { #[throws(AE)] pub fn prep_access_account(&mut self, ma: &MainOpts, diff --git a/daemon/sse.rs b/daemon/sse.rs index 57c7c189..bdc6dc00 100644 --- a/daemon/sse.rs +++ b/daemon/sse.rs @@ -21,15 +21,15 @@ struct UpdateReaderWN { to_send: UpdateId, } +#[derive(Deref)] // no DerefMut struct UpdateReader { - wn: UpdateReaderWN, + #[deref] wn: UpdateReaderWN, overflow: Option>>, gref: InstanceRef, keepalives: Wrapping, ending_send: Option>>, init_confirmation_send: iter::Once<()>, } -deref_to_field!{UpdateReader, UpdateReaderWN, wn} // no DerefMut impl UpdateReaderWN { #[throws(io::Error)] diff --git a/src/accounts.rs b/src/accounts.rs index 03655b2c..fb3c6fe7 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -37,6 +37,7 @@ pub struct AccountName { /// Record of acess for a player. Newtype prevents mutable access /// without invalidating old tokens and permissions check. #[derive(Serialize,Deserialize,Debug)] +#[derive(Deref)] // No DerefMut, to make sure we save properly etc. #[serde(transparent)] pub struct AccessRecord(Arc); @@ -244,9 +245,6 @@ impl FromStr for AccountName { //---------- AccessRecord ---------- -// No DerefMut, to make sure we save properly etc. -deref_to_field!{AccessRecord, Arc, 0} - impl AccessRecord { pub fn new_unset() -> Self{ Self( Arc::new(PlayerAccessUnset) ) }