Skip to content

Commit 050ae2e

Browse files
committed
Adjust unnamed pipe examples
1 parent 5bcd669 commit 050ae2e

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

examples/unnamed_pipe/sync/side_a.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ pub(crate) fn emain(handle_sender: mpsc::SyncSender<Handle>) -> io::Result<()> {
3232
assert_eq!(buf.trim(), "Hello from side B!");
3333
//{
3434
Ok(())
35-
} //}
35+
}
3636
#[allow(dead_code)]
37-
fn main() {}
37+
fn main() {} //}

examples/unnamed_pipe/sync/side_b.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ pub(crate) fn emain(handle: Handle) -> io::Result<()> {
1919
tx.write_all(b"Hello from side B!\n")?;
2020
//{
2121
Ok(())
22-
} //}
22+
}
2323
#[allow(dead_code)]
24-
fn main() {}
24+
fn main() {} //}

examples/unnamed_pipe/tokio/side_a.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ pub(crate) async fn emain(handle_sender: oneshot::Sender<Handle>) -> io::Result<
3333
assert_eq!(buf.trim(), "Hello from side B!");
3434
//{
3535
Ok(())
36-
} //}
36+
}
3737
#[allow(dead_code)]
38-
fn main() {}
38+
fn main() {} //}

examples/unnamed_pipe/tokio/side_b.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ pub(crate) async fn emain(handle: Handle) -> io::Result<()> {
2020
tx.write_all(b"Hello from side B!\n").await?;
2121
//{
2222
Ok(())
23-
} //}
23+
}
2424
#[allow(dead_code)]
25-
fn main() {}
25+
fn main() {} //}

src/unnamed_pipe/tokio.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
//! Tokio-based asynchronous unnamed pipes.
22
//!
33
//! See the [parent-level documentation](super) for more.
4+
//!
5+
//! # Examples
6+
//! See [`pipe()`].
47
58
impmod! {unnamed_pipe::tokio,
69
Recver as RecverImpl,
@@ -14,6 +17,17 @@ use std::io;
1417
///
1518
/// The platform-specific builders in the `os` module of the crate might be more helpful if extra
1619
/// configuration for the pipe is needed.
20+
///
21+
/// # Examples
22+
/// ## Basic communication
23+
/// In a parent process, within a Tokio runtime:
24+
/// ```no_run
25+
#[doc = doctest_file::include_doctest!("examples/unnamed_pipe/sync/side_a.rs")]
26+
/// ```
27+
/// In a child process, within a Tokio runtime:
28+
/// ```no_run
29+
#[doc = doctest_file::include_doctest!("examples/unnamed_pipe/sync/side_b.rs")]
30+
/// ```
1731
#[inline]
1832
pub fn pipe() -> io::Result<(Sender, Recver)> {
1933
pipe_impl()

0 commit comments

Comments
 (0)