Skip to content

Commit

Permalink
fix(anstream): Loosen StripStream's bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jan 16, 2024
1 parent a55990c commit 6fb197d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions crates/anstream/src/strip.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use crate::adapter::StripBytes;
use crate::stream::AsLockedWrite;
use crate::stream::RawStream;
use crate::stream::IsTerminal;

/// Only pass printable data to the inner `Write`
#[derive(Debug)]
pub struct StripStream<S>
where
S: RawStream,
S: std::io::Write,
{
raw: S,
state: StripBytes,
}

impl<S> StripStream<S>
where
S: RawStream,
S: std::io::Write,
{
/// Only pass printable data to the inner `Write`
#[inline]
Expand All @@ -25,12 +25,18 @@ where
}
}

/// Get the wrapped [`RawStream`]
/// Get the wrapped [`std::io::Write`]
#[inline]
pub fn into_inner(self) -> S {
self.raw
}
}

impl<S> StripStream<S>
where
S: std::io::Write,
S: IsTerminal,
{
#[inline]
pub fn is_terminal(&self) -> bool {
self.raw.is_terminal()
Expand Down Expand Up @@ -69,7 +75,7 @@ impl StripStream<std::io::Stderr> {

impl<S> std::io::Write for StripStream<S>
where
S: RawStream + AsLockedWrite,
S: std::io::Write + AsLockedWrite,
{
// Must forward all calls to ensure locking happens appropriately
#[inline]
Expand Down

0 comments on commit 6fb197d

Please sign in to comment.