mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
wc: split WordCountable trait to exclude inner_file on wasi
This commit is contained in:
@@ -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<Self>;
|
||||
|
||||
@@ -49,3 +66,12 @@ impl WordCountable for File {
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "wasi")]
|
||||
impl WordCountable for File {
|
||||
type Buffered = BufReader<Self>;
|
||||
|
||||
fn buffered(self) -> Self::Buffered {
|
||||
BufReader::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user