Release embassy-net v0.1

This commit is contained in:
Dario Nieuwenhuis
2023-06-29 19:51:16 +02:00
parent 4feabb13bf
commit 6eac49186d
11 changed files with 238 additions and 27 deletions

View File

@ -419,7 +419,29 @@ impl<D: Driver + 'static> Stack<D> {
})
.await?;
use embassy_hal_common::drop::OnDrop;
#[must_use = "to delay the drop handler invocation to the end of the scope"]
struct OnDrop<F: FnOnce()> {
f: core::mem::MaybeUninit<F>,
}
impl<F: FnOnce()> OnDrop<F> {
fn new(f: F) -> Self {
Self {
f: core::mem::MaybeUninit::new(f),
}
}
fn defuse(self) {
core::mem::forget(self)
}
}
impl<F: FnOnce()> Drop for OnDrop<F> {
fn drop(&mut self) {
unsafe { self.f.as_ptr().read()() }
}
}
let drop = OnDrop::new(|| {
self.with_mut(|s, i| {
let socket = s.sockets.get_mut::<dns::Socket>(i.dns_socket);