chiark / gitweb /
hidden: Make PieceRenderInstructions deref to PriOcculted
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 16 Mar 2021 12:02:31 +0000 (12:02 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 16 Mar 2021 12:04:58 +0000 (12:04 +0000)
This makes call sites somewhat nicer, especially as we move more
stuff.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/pcrender.rs

index 7256295029a9aeade2a3a6cb0eba497e14fc6ec7..4530b100653d54e00c88cbebbe2970b066ba7c2c 100644 (file)
@@ -16,6 +16,7 @@ pub struct PieceRenderInstructions {
   pub vpid: VisiblePieceId,
   pub occulted: PriOcculted,
 }
+deref_to_field!{PieceRenderInstructions, PriOcculted, occulted}
 
 #[derive(Debug,Clone)]
 pub enum PriOccultedGeneral<P,Z> {
@@ -135,7 +136,7 @@ impl PieceRenderInstructions {
                          gpc: &GPiece, ipc: &IPiece) -> Html
   {
     let pri = self;
-    let instead = pri.occulted.instead(ioccults, ipc)?;
+    let instead = pri.instead(ioccults, ipc)?;
 
     let o: &dyn OutlineTrait = match instead {
       Left(_) => Borrow::<dyn PieceTrait>::borrow(&ipc.p).dyn_upcast(),
@@ -186,7 +187,7 @@ impl PieceRenderInstructions {
   #[throws(IE)]
   pub fn describe_fallible(&self, ioccults: &IOccults,
                            gpc: &GPiece, ipc: &IPiece) -> Html {
-    match self.occulted.instead(ioccults, ipc)? {
+    match self.instead(ioccults, ipc)? {
       Left(_y) => ipc.p.describe_html(gpc)?,
       Right(i) => i.describe_html()?,
     }