From eff9168846df1b0b4fa2be75e061c63c2bb8c942 Mon Sep 17 00:00:00 2001 From: Bailey Quarters Date: Mon, 24 Mar 2025 19:53:36 +0100 Subject: [PATCH] Make CDC ACM state constructor `const` --- embassy-usb/src/class/cdc_acm.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/embassy-usb/src/class/cdc_acm.rs b/embassy-usb/src/class/cdc_acm.rs index c5b1a56fe..ea9d9fb7b 100644 --- a/embassy-usb/src/class/cdc_acm.rs +++ b/embassy-usb/src/class/cdc_acm.rs @@ -47,10 +47,10 @@ impl<'a> Default for State<'a> { impl<'a> State<'a> { /// Create a new `State`. - pub fn new() -> Self { + pub const fn new() -> Self { Self { control: MaybeUninit::uninit(), - shared: ControlShared::default(), + shared: ControlShared::new(), } } } @@ -92,6 +92,12 @@ struct ControlShared { impl Default for ControlShared { fn default() -> Self { + Self::new() + } +} + +impl ControlShared { + const fn new() -> Self { ControlShared { dtr: AtomicBool::new(false), rts: AtomicBool::new(false), @@ -105,9 +111,7 @@ impl Default for ControlShared { changed: AtomicBool::new(false), } } -} -impl ControlShared { fn changed(&self) -> impl Future + '_ { poll_fn(|cx| { if self.changed.load(Ordering::Relaxed) {