Use inline const for initializing arrays. (#3567)

This commit is contained in:
Dario Nieuwenhuis
2024-11-24 20:58:48 +01:00
committed by GitHub
parent b9408f0510
commit aaad8450e9
19 changed files with 46 additions and 69 deletions

View File

@@ -26,13 +26,11 @@ pub struct State<const MTU: usize, const N_RX: usize, const N_TX: usize> {
}
impl<const MTU: usize, const N_RX: usize, const N_TX: usize> State<MTU, N_RX, N_TX> {
const NEW_PACKET: PacketBuf<MTU> = PacketBuf::new();
/// Create a new channel state.
pub const fn new() -> Self {
Self {
rx: [Self::NEW_PACKET; N_RX],
tx: [Self::NEW_PACKET; N_TX],
rx: [const { PacketBuf::new() }; N_RX],
tx: [const { PacketBuf::new() }; N_TX],
inner: MaybeUninit::uninit(),
}
}