diff --git a/src/uu/wc/src/countable.rs b/src/uu/wc/src/countable.rs index 5b2ad7a99..32d565538 100644 --- a/src/uu/wc/src/countable.rs +++ b/src/uu/wc/src/countable.rs @@ -20,13 +20,20 @@ pub trait WordCountable: AsFd + AsRawFd + Read { fn inner_file(&mut self) -> Option<&mut File>; } -#[cfg(not(unix))] +#[cfg(all(not(unix), not(target_os = "wasi")))] pub trait WordCountable: Read { type Buffered: BufRead; fn buffered(self) -> Self::Buffered; fn inner_file(&mut self) -> Option<&mut File>; } +#[cfg(target_os = "wasi")] +pub trait WordCountable: Read { + type Buffered: BufRead; + fn buffered(self) -> Self::Buffered; +} + +#[cfg(not(target_os = "wasi"))] impl WordCountable for StdinLock<'_> { type Buffered = Self; @@ -38,6 +45,16 @@ impl WordCountable for StdinLock<'_> { } } +#[cfg(target_os = "wasi")] +impl WordCountable for StdinLock<'_> { + type Buffered = Self; + + fn buffered(self) -> Self::Buffered { + self + } +} + +#[cfg(not(target_os = "wasi"))] impl WordCountable for File { type Buffered = BufReader; @@ -49,3 +66,12 @@ impl WordCountable for File { Some(self) } } + +#[cfg(target_os = "wasi")] +impl WordCountable for File { + type Buffered = BufReader; + + fn buffered(self) -> Self::Buffered { + BufReader::new(self) + } +}