Skip to content

Commit 55f0f06

Browse files
committed
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.
1 parent df21758 commit 55f0f06

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

crates/wasi-common/src/pipe.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ use std::sync::{Arc, RwLock};
2020
/// ```no_run
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()));
@@ -116,10 +117,11 @@ impl<R: Read + Any + Send + Sync> WasiFile for ReadPipe<R> {
116117
/// ```no_run
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)