From dcf0c6ce5ce21647640b2b35715ede50a5a97881 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Wed, 18 Nov 2026 16:38:51 -0700 Subject: dyn Module fun this also seemed a good time to clean up the bibliography and publish it Force-Push: yes Change-Id: Ia8014fb84c1af37be4f3c915b8b8f70bc2022034 --- src/module.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/module.rs') diff --git a/src/module.rs b/src/module.rs index c859bd3..d10e436 100644 --- a/src/module.rs +++ b/src/module.rs @@ -10,10 +10,23 @@ pub use time::TimeModule; pub mod time; -pub trait Module { +/* As with Facility, we need a separate trait for the stuff that wouldn't be + * dyn-compatible. + */ +pub trait CreatableModule: Module + Sized { const REQUIRED_FACILITIES: FacilityType; - fn new() -> Result>>; + fn new() -> Result; + + /* The only way to coerce to dyn is to return as it! */ + fn as_box<'a>(self) -> Box + where Self: 'a + { + Box::new(self) + } +} + +pub trait Module { fn format(&mut self) -> String; fn sleep_duration(&self) -> Option; } -- cgit 1.4.1