use crate::*; use std::sync::Arc; use crate::content::{Content, ContentUpdate, ContentWrapper}; use super::traits::*; pub struct EmptyRightSide; impl RightSide for EmptyRightSide { fn refresh(&mut self, _engine: &Engine, _hero: Entity) -> Result<()> { unreachable!() } fn base(&self) -> &Arc { unreachable!() } } pub struct PageContent { content: Content, tooltip: Arc, right_side: Box, } impl PageContent { pub fn new(content: Content, tooltip: Arc, right_side: R) -> Self where R: RightSide + 'static, { Self { content, tooltip, right_side: Box::new(right_side), } } } impl PageContentWrapper for PageContent where Content: ContentUpdate, { fn content(&self) -> &dyn ContentWrapper { &self.content } fn content_mut(&mut self) -> &mut dyn ContentWrapper { &mut self.content } fn tooltip(&self) -> &Arc { &self.tooltip } fn right_side(&self) -> &dyn RightSide { &*self.right_side } fn right_side_mut(&mut self) -> &mut dyn RightSide { &mut *self.right_side } }