Skip to content

Commit d1fec5e

Browse files
authored
Fix documentation examples in pipe.rs (#11792)
* Fix documentation examples in pipe.rs Replace todo!() placeholders in documentation examples with actual working code The examples now show how to properly create random, clocks, and sched instances needed for WasiCtx::new() function. * Run pipe documentation examples
1 parent c33c8b8 commit d1fec5e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

crates/wasi-common/src/pipe.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ use std::sync::{Arc, RwLock};
1717
///
1818
/// A variety of `From` impls are provided so that common pipe types are easy to create. For example:
1919
///
20-
/// ```no_run
20+
/// ```rust
2121
/// use wasi_common::{pipe::ReadPipe, WasiCtx, Table};
2222
/// let stdin = ReadPipe::from("hello from stdin!");
23-
/// // Brint these instances from elsewhere (e.g. wasi-cap-std-sync):
24-
/// let random = todo!();
25-
/// let clocks = todo!();
26-
/// let sched = todo!();
23+
/// // Bring these instances from elsewhere (e.g. wasi-cap-std-sync or wasi-cap-std-tokio):
24+
/// use wasi_common::sync::{random_ctx, clocks_ctx, sched_ctx};
25+
/// let random = random_ctx();
26+
/// let clocks = clocks_ctx();
27+
/// let sched = sched_ctx();
2728
/// let table = Table::new();
2829
/// let mut ctx = WasiCtx::new(random, clocks, sched, table);
2930
/// ctx.set_stdin(Box::new(stdin.clone()));
@@ -113,13 +114,14 @@ impl<R: Read + Any + Send + Sync> WasiFile for ReadPipe<R> {
113114

114115
/// A virtual pipe write end.
115116
///
116-
/// ```no_run
117+
/// ```rust
117118
/// use wasi_common::{pipe::WritePipe, WasiCtx, Table};
118119
/// let stdout = WritePipe::new_in_memory();
119-
/// // Brint these instances from elsewhere (e.g. wasi-cap-std-sync):
120-
/// let random = todo!();
121-
/// let clocks = todo!();
122-
/// let sched = todo!();
120+
/// // Bring these instances from elsewhere (e.g. wasi-cap-std-sync or wasi-cap-std-tokio):
121+
/// use wasi_common::sync::{random_ctx, clocks_ctx, sched_ctx};
122+
/// let random = random_ctx();
123+
/// let clocks = clocks_ctx();
124+
/// let sched = sched_ctx();
123125
/// let table = Table::new();
124126
/// let mut ctx = WasiCtx::new(random, clocks, sched, table);
125127
/// ctx.set_stdout(Box::new(stdout.clone()));

0 commit comments

Comments
 (0)