Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Fix documentation examples in pipe.rs (#11792)

jiang1997d1fec5e6355f
diff --git a/crates/wasi-common/src/pipe.rs b/crates/wasi-common/src/pipe.rs
index ccad53c395..9e70e20bd3 100644
--- a/crates/wasi-common/src/pipe.rs
+++ b/crates/wasi-common/src/pipe.rs
@@ -17,13 +17,14 @@ use std::sync::{Arc, RwLock};
///
/// A variety of `From` impls are provided so that common pipe types are easy to create. For example:
///
-/// ```no_run
+/// ```rust
/// use wasi_common::{pipe::ReadPipe, WasiCtx, Table};
/// let stdin = ReadPipe::from("hello from stdin!");
-/// // Brint these instances from elsewhere (e.g. wasi-cap-std-sync):
-/// let random = todo!();
-/// let clocks = todo!();
-/// let sched = todo!();
+/// // Bring these instances from elsewhere (e.g. wasi-cap-std-sync or wasi-cap-std-tokio):
+/// use wasi_common::sync::{random_ctx, clocks_ctx, sched_ctx};
+/// let random = random_ctx();
+/// let clocks = clocks_ctx();
+/// let sched = sched_ctx();
/// let table = Table::new();
/// let mut ctx = WasiCtx::new(random, clocks, sched, table);
/// ctx.set_stdin(Box::new(stdin.clone()));
@@ -113,13 +114,14 @@ impl<R: Read + Any + Send + Sync> WasiFile for ReadPipe<R> {
/// A virtual pipe write end.
///
-/// ```no_run
+/// ```rust
/// use wasi_common::{pipe::WritePipe, WasiCtx, Table};
/// let stdout = WritePipe::new_in_memory();
-/// // Brint these instances from elsewhere (e.g. wasi-cap-std-sync):
-/// let random = todo!();
-/// let clocks = todo!();
-/// let sched = todo!();
+/// // Bring these instances from elsewhere (e.g. wasi-cap-std-sync or wasi-cap-std-tokio):
+/// use wasi_common::sync::{random_ctx, clocks_ctx, sched_ctx};
+/// let random = random_ctx();
+/// let clocks = clocks_ctx();
+/// let sched = sched_ctx();
/// let table = Table::new();
/// let mut ctx = WasiCtx::new(random, clocks, sched, table);
/// ctx.set_stdout(Box::new(stdout.clone()));