This error message stems from the fact that array initialization of the form [expr; N]
requires the type of expr
to implement Copy
.
See also this website.
In your case, you can just use e.g. control_tx: Default::default()
.
Another option that has come up in a recent thread (that I’m currently not finding for some reason) is to define some const NO_SENDER: Option<Sender<ControlCommand>> = None;
and use [NO_SENDER; 8]
. I’m personally feeling like: if constants work, they ought to, eventually, get around to make None
work directly as well. Edit2: Nevermind it’s already implemented, just not stabilized. On nightly with #![feature(const_in_array_repeat_expressions)]
, using None
directly works.
Edit - this thread: