From: Ian Jackson Date: Wed, 24 Mar 2021 18:40:51 +0000 (+0000) Subject: hidden: Provide active_views, more useful X-Git-Tag: otter-0.5.0~447 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=028cbf64b712fea3377e36b25e37ae6b0d5976e5;p=otter.git hidden: Provide active_views, more useful This is not dangerous because we only give out non-mut reference. Signed-off-by: Ian Jackson --- diff --git a/src/hidden.rs b/src/hidden.rs index f136d55b..0d31a972 100644 --- a/src/hidden.rs +++ b/src/hidden.rs @@ -51,14 +51,14 @@ pub struct Occultation { #[derive(Clone,Debug,Serialize,Deserialize)] pub struct OccultationViews { - views: Vec, - #[serde(default)] defview: OccultationKind, + pub views: Vec, + #[serde(default)] pub defview: OccultationKind, } #[derive(Clone,Debug,Serialize,Deserialize)] pub struct OccultView { - #[serde(default)] occult: OccultationKind, - players: Vec, + #[serde(default)] pub occult: OccultationKind, + pub players: Vec, } #[derive(Clone,Copy,Debug,Serialize,Deserialize)] @@ -83,12 +83,12 @@ impl PieceOccult { pub fn is_active(&self) -> bool { self.active.is_some() } #[throws(IE)] - pub fn active_nondefault_views(&self, goccults: &GameOccults) - -> Option { + pub fn active_views<'r>(&'r self, goccults: &'r GameOccults) + -> Option<&'r OccultationViews> { if let Some(occid) = self.active { let occ = goccults.occults.get(occid).ok_or_else( || internal_error_bydebug(&self))?; - Some(occ.views.views.len()) + Some(&occ.views) } else { None }