PacketQueue::new() uses ::init() when in nightly

This commit is contained in:
Davide Della Giustina 2023-02-28 14:34:26 +00:00
parent 90f2939bf6
commit c1e93c0904
No known key found for this signature in database

View File

@ -30,13 +30,24 @@ pub struct PacketQueue<const TX: usize, const RX: usize> {
impl<const TX: usize, const RX: usize> PacketQueue<TX, RX> { impl<const TX: usize, const RX: usize> PacketQueue<TX, RX> {
pub const fn new() -> Self { pub const fn new() -> Self {
const NEW_TDES: TDes = TDes::new(); #[cfg(feature = "nightly")]
const NEW_RDES: RDes = RDes::new(); {
Self { let mut this = core::mem::MaybeUninit::uninit();
tx_desc: [NEW_TDES; TX], unsafe {
rx_desc: [NEW_RDES; RX], Self::init(&mut this);
tx_buf: [Packet([0; TX_BUFFER_SIZE]); TX], this.assume_init()
rx_buf: [Packet([0; RX_BUFFER_SIZE]); RX], }
}
#[cfg(not(feature = "nightly"))]
{
const NEW_TDES: TDes = TDes::new();
const NEW_RDES: RDes = RDes::new();
Self {
tx_desc: [NEW_TDES; TX],
rx_desc: [NEW_RDES; RX],
tx_buf: [Packet([0; TX_BUFFER_SIZE]); TX],
rx_buf: [Packet([0; RX_BUFFER_SIZE]); RX],
}
} }
} }