aboutsummaryrefslogtreecommitdiff
path: root/embassy-net/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-06-29 20:01:10 +0200
committerGitHub <[email protected]>2023-06-29 20:01:10 +0200
commitba4344429264fa7beb99ab19c09059c2d531716d (patch)
tree3cbd9c15c68c7ee3859a17ec6d6fc7150e569686 /embassy-net/src
parent4feabb13bfbda46de74be09566118adc1ba49d5d (diff)
parent6eac49186d5a5da4c310027e59adcd0bf44ae514 (diff)
Merge pull request #1601 from embassy-rs/net-release
Release embassy-net v0.1
Diffstat (limited to 'embassy-net/src')
-rw-r--r--embassy-net/src/lib.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/embassy-net/src/lib.rs b/embassy-net/src/lib.rs
index 17a7a22a2..840d7a09a 100644
--- a/embassy-net/src/lib.rs
+++ b/embassy-net/src/lib.rs
@@ -419,7 +419,29 @@ impl<D: Driver + 'static> Stack<D> {
419 }) 419 })
420 .await?; 420 .await?;
421 421
422 use embassy_hal_common::drop::OnDrop; 422 #[must_use = "to delay the drop handler invocation to the end of the scope"]
423 struct OnDrop<F: FnOnce()> {
424 f: core::mem::MaybeUninit<F>,
425 }
426
427 impl<F: FnOnce()> OnDrop<F> {
428 fn new(f: F) -> Self {
429 Self {
430 f: core::mem::MaybeUninit::new(f),
431 }
432 }
433
434 fn defuse(self) {
435 core::mem::forget(self)
436 }
437 }
438
439 impl<F: FnOnce()> Drop for OnDrop<F> {
440 fn drop(&mut self) {
441 unsafe { self.f.as_ptr().read()() }
442 }
443 }
444
423 let drop = OnDrop::new(|| { 445 let drop = OnDrop::new(|| {
424 self.with_mut(|s, i| { 446 self.with_mut(|s, i| {
425 let socket = s.sockets.get_mut::<dns::Socket>(i.dns_socket); 447 let socket = s.sockets.get_mut::<dns::Socket>(i.dns_socket);