chiark / gitweb /
hidden: style: Make get take &I and remove some pointles borrow calls
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Apr 2022 17:40:31 +0000 (18:40 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Apr 2022 18:00:19 +0000 (19:00 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/hidden.rs
src/occultilks.rs

index c9761cf57cfd587a96ac7fd116f92c013b16d782..cacef9a1365458323fcbe121ee720e17af88c9c0 100644 (file)
@@ -408,8 +408,7 @@ impl IPiece {
       None => Right({
         let occilk = self.occilk.as_ref()
           .ok_or_else(|| internal_logic_error(format!(
-            "occulted non-occultable {:?}", self)))?
-          .borrow();
+            "occulted non-occultable {:?}", self)))?;
         let occ_data = ioccults.ilks.get(occilk)
           .ok_or_else(|| internal_logic_error(format!(
             "occulted ilk vanished {:?} {:?}", self, occilk)))?;
@@ -698,7 +697,6 @@ fn recalculate_occultation_general<
       if_chain!{
         if occ.notches.is_empty();
         if let Some(ilk) = wants!( ipc.occilk.as_ref() );
-        let ilk = ilk.borrow();
         if let Some(ilk) = wants!( ioccults.ilks.get(ilk) );
         if let Some(bbox) = want!( Ok = ilk.p_occ.bbox_approx() );
         if let Some(size) = want!( Ok = bbox.br() - bbox.tl(), ?(bbox) );
index f9d6ccd759e03653dfb8806d5ad310610a079cf6..f7ac81a76b73a9f0070466f0cf934fcab57291ac 100644 (file)
@@ -39,7 +39,7 @@ pub struct Data {
 
 impl OccultIlks {
   #[throws(as Option)]
-  pub fn get<I: Borrow<Id>>(&self, id: I) -> &V {
+  pub fn get<I: Borrow<Id>>(&self, id: &I) -> &V {
     &self.table.get(*id.borrow())?.v
   }