Skip to content

Commit 9ba5b5e

Browse files
committed
add experimental oneshot channel
The `oneshot` channel is gated under the `oneshot_channel` feature. Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
1 parent e29fcf4 commit 9ba5b5e

4 files changed

Lines changed: 474 additions & 4 deletions

File tree

library/std/src/sync/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ pub use alloc_crate::sync::{Arc, Weak};
184184
#[unstable(feature = "mpmc_channel", issue = "126840")]
185185
pub mod mpmc;
186186
pub mod mpsc;
187+
#[unstable(feature = "oneshot_channel", issue = "143674")]
188+
pub mod oneshot;
187189

188190
pub(crate) mod once; // `pub(crate)` for the `sys::sync::once` implementations and `LazyLock`.
189191

library/std/src/sync/mpmc/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ impl<T> Clone for Sender<T> {
654654
#[unstable(feature = "mpmc_channel", issue = "126840")]
655655
impl<T> fmt::Debug for Sender<T> {
656656
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
657-
f.pad("Sender { .. }")
657+
f.debug_struct("Sender").finish_non_exhaustive()
658658
}
659659
}
660660

@@ -1380,7 +1380,7 @@ impl<T> Clone for Receiver<T> {
13801380
#[unstable(feature = "mpmc_channel", issue = "126840")]
13811381
impl<T> fmt::Debug for Receiver<T> {
13821382
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1383-
f.pad("Receiver { .. }")
1383+
f.debug_struct("Receiver").finish_non_exhaustive()
13841384
}
13851385
}
13861386

library/std/src/sync/mpsc.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,8 +1114,10 @@ impl<T> error::Error for SendError<T> {}
11141114
impl<T> fmt::Debug for TrySendError<T> {
11151115
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11161116
match *self {
1117-
TrySendError::Full(..) => "Full(..)".fmt(f),
1118-
TrySendError::Disconnected(..) => "Disconnected(..)".fmt(f),
1117+
TrySendError::Full(..) => f.debug_tuple("TrySendError::Full").finish_non_exhaustive(),
1118+
TrySendError::Disconnected(..) => {
1119+
f.debug_tuple("TrySendError::Disconnected").finish_non_exhaustive()
1120+
}
11191121
}
11201122
}
11211123
}

0 commit comments

Comments
 (0)