chiark / gitweb /
Switch to deriving Deref
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 4 May 2022 20:40:19 +0000 (21:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 4 May 2022 20:51:22 +0000 (21:51 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
cli/clisupport.rs
daemon/sse.rs
src/accounts.rs

index 67d1ec85888e9c5a54b5b15339d23df841afd353..fda18f10b950105f121c38f84a6acedd7853b6fa 100644 (file)
@@ -295,12 +295,11 @@ impl String {
   fn leak(self) -> &'static str { Box::<str>::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,
index 57c7c1893baa6b587fba1aba4767ec4b8ab8abac..bdc6dc00870353677dd1418770b44ac9f8bb8ae9 100644 (file)
@@ -21,15 +21,15 @@ struct UpdateReaderWN {
   to_send: UpdateId,
 }
 
+#[derive(Deref)] // no DerefMut
 struct UpdateReader {
-  wn: UpdateReaderWN,
+  #[deref] wn: UpdateReaderWN,
   overflow: Option<io::Cursor<Box<[u8]>>>,
   gref: InstanceRef,
   keepalives: Wrapping<u32>,
   ending_send: Option<io::Cursor<Box<[u8]>>>,
   init_confirmation_send: iter::Once<()>,
 }
-deref_to_field!{UpdateReader, UpdateReaderWN, wn} // no DerefMut
 
 impl UpdateReaderWN {
   #[throws(io::Error)]
index 03655b2cd07a2e7de387c4854fe5d2e196842ca6..fb3c6fe7cb8504e8361702e3030f93a6be42503a 100644 (file)
@@ -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<dyn PlayerAccessSpec>);
 
@@ -244,9 +245,6 @@ impl FromStr for AccountName {
 
 //---------- AccessRecord ----------
 
-// No DerefMut, to make sure we save properly etc.
-deref_to_field!{AccessRecord, Arc<dyn PlayerAccessSpec>, 0}
-
 impl AccessRecord {
   pub fn new_unset() -> Self{ Self( Arc::new(PlayerAccessUnset) ) }