Merge pull request #4000 from quarters78/main
Make CDC ACM state constructor `const`
This commit is contained in:
commit
9d009e59e5
@ -47,10 +47,10 @@ impl<'a> Default for State<'a> {
|
|||||||
|
|
||||||
impl<'a> State<'a> {
|
impl<'a> State<'a> {
|
||||||
/// Create a new `State`.
|
/// Create a new `State`.
|
||||||
pub fn new() -> Self {
|
pub const fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
control: MaybeUninit::uninit(),
|
control: MaybeUninit::uninit(),
|
||||||
shared: ControlShared::default(),
|
shared: ControlShared::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,6 +92,12 @@ struct ControlShared {
|
|||||||
|
|
||||||
impl Default for ControlShared {
|
impl Default for ControlShared {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ControlShared {
|
||||||
|
const fn new() -> Self {
|
||||||
ControlShared {
|
ControlShared {
|
||||||
dtr: AtomicBool::new(false),
|
dtr: AtomicBool::new(false),
|
||||||
rts: AtomicBool::new(false),
|
rts: AtomicBool::new(false),
|
||||||
@ -105,9 +111,7 @@ impl Default for ControlShared {
|
|||||||
changed: AtomicBool::new(false),
|
changed: AtomicBool::new(false),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl ControlShared {
|
|
||||||
fn changed(&self) -> impl Future<Output = ()> + '_ {
|
fn changed(&self) -> impl Future<Output = ()> + '_ {
|
||||||
poll_fn(|cx| {
|
poll_fn(|cx| {
|
||||||
if self.changed.load(Ordering::Relaxed) {
|
if self.changed.load(Ordering::Relaxed) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user