Skip to content

Commit

Permalink
Add back ::none() constructor, format
Browse files Browse the repository at this point in the history
  • Loading branch information
flub committed Dec 18, 2024
1 parent 33fdb0c commit c61034c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion iroh/src/magicsock/relay_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ impl ActiveRelayActor {
// When this future has an inner, it is a future which is currently sending
// something to the relay server. Nothing else can be sent to the relay server at
// the same time.
let mut relay_send_fut = std::pin::pin!(MaybeFuture::default());
let mut relay_send_fut = std::pin::pin!(MaybeFuture::none());

loop {
// If a read error occurred on the connection it might have been lost. But we
Expand Down
8 changes: 7 additions & 1 deletion iroh/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! Utilities used in [`iroh`][`crate`]
use pin_project::pin_project;
use std::{
future::Future,
pin::Pin,
task::{Context, Poll},
};

use pin_project::pin_project;

/// A future which may not be present.
///
/// This is a single type which may optionally contain a future. If there is no inner
Expand All @@ -23,6 +24,11 @@ pub(crate) enum MaybeFuture<T> {
}

impl<T> MaybeFuture<T> {
/// Creates a [`MaybeFuture`] without an inner future.
pub(crate) fn none() -> Self {
Self::default()
}

/// Clears the value
pub(crate) fn set_none(mut self: Pin<&mut Self>) {
self.as_mut().project_replace(Self::None);
Expand Down

0 comments on commit c61034c

Please sign in to comment.