From 13aedbd74cdf7ea6212f02963c09e30c35e5274d Mon Sep 17 00:00:00 2001 From: jiang1997 Date: Sun, 5 Oct 2025 07:18:21 +0800 Subject: [PATCH 1/2] 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. --- crates/wasi-common/src/pipe.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/wasi-common/src/pipe.rs b/crates/wasi-common/src/pipe.rs index ccad53c39536..b2d93637e781 100644 --- a/crates/wasi-common/src/pipe.rs +++ b/crates/wasi-common/src/pipe.rs @@ -20,10 +20,11 @@ use std::sync::{Arc, RwLock}; /// ```no_run /// 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())); @@ -116,10 +117,11 @@ impl WasiFile for ReadPipe { /// ```no_run /// 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())); From c0bf4e5c8c6427804c0e963bb495bedf623fb2b5 Mon Sep 17 00:00:00 2001 From: jiang1997 Date: Tue, 7 Oct 2025 16:39:06 +0800 Subject: [PATCH 2/2] Run pipe documentation examples --- crates/wasi-common/src/pipe.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/wasi-common/src/pipe.rs b/crates/wasi-common/src/pipe.rs index b2d93637e781..9e70e20bd3ed 100644 --- a/crates/wasi-common/src/pipe.rs +++ b/crates/wasi-common/src/pipe.rs @@ -17,7 +17,7 @@ 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!"); /// // Bring these instances from elsewhere (e.g. wasi-cap-std-sync or wasi-cap-std-tokio): @@ -114,7 +114,7 @@ impl WasiFile for ReadPipe { /// A virtual pipe write end. /// -/// ```no_run +/// ```rust /// use wasi_common::{pipe::WritePipe, WasiCtx, Table}; /// let stdout = WritePipe::new_in_memory(); /// // Bring these instances from elsewhere (e.g. wasi-cap-std-sync or wasi-cap-std-tokio):