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,6 +30,16 @@ 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 {
#[cfg(feature = "nightly")]
{
let mut this = core::mem::MaybeUninit::uninit();
unsafe {
Self::init(&mut this);
this.assume_init()
}
}
#[cfg(not(feature = "nightly"))]
{
const NEW_TDES: TDes = TDes::new(); const NEW_TDES: TDes = TDes::new();
const NEW_RDES: RDes = RDes::new(); const NEW_RDES: RDes = RDes::new();
Self { Self {
@ -39,6 +49,7 @@ impl<const TX: usize, const RX: usize> PacketQueue<TX, RX> {
rx_buf: [Packet([0; RX_BUFFER_SIZE]); RX], rx_buf: [Packet([0; RX_BUFFER_SIZE]); RX],
} }
} }
}
// Allow to initialize a Self without requiring it to go on the stack // Allow to initialize a Self without requiring it to go on the stack
#[cfg(feature = "nightly")] #[cfg(feature = "nightly")]