Move `std` impl from `lib.rs` to `bridge.rs`
This reduces the number of compilation conditions.
This commit is contained in:
parent
94768d3f70
commit
505ecd8a2e
|
@ -254,3 +254,35 @@ impl<T: super::Write> super::Write for ToStd<T> {
|
||||||
self.0.write_all(buf)
|
self.0.write_all(buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<R: std::io::Read> super::Read for std::io::BufReader<R> {
|
||||||
|
#[inline]
|
||||||
|
fn read(&mut self, buf: &mut [u8]) -> super::Result<usize> { Ok(std::io::Read::read(self, buf)?) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<R: std::io::Read> super::BufRead for std::io::BufReader<R> {
|
||||||
|
#[inline]
|
||||||
|
fn fill_buf(&mut self) -> super::Result<&[u8]> { Ok(std::io::BufRead::fill_buf(self)?) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn consume(&mut self, amount: usize) { std::io::BufRead::consume(self, amount) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl std::io::Write for super::Sink {
|
||||||
|
#[inline]
|
||||||
|
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { Ok(buf.len()) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn write_all(&mut self, _: &[u8]) -> std::io::Result<()> { Ok(()) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn flush(&mut self) -> std::io::Result<()> { Ok(()) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<W: std::io::Write> super::Write for std::io::BufWriter<W> {
|
||||||
|
#[inline]
|
||||||
|
fn write(&mut self, buf: &[u8]) -> super::Result<usize> { Ok(std::io::Write::write(self, buf)?) }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn flush(&mut self) -> super::Result<()> { Ok(std::io::Write::flush(self)?) }
|
||||||
|
}
|
||||||
|
|
|
@ -163,12 +163,6 @@ impl Read for &[u8] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<R: std::io::Read> Read for std::io::BufReader<R> {
|
|
||||||
#[inline]
|
|
||||||
fn read(&mut self, buf: &mut [u8]) -> Result<usize> { Ok(std::io::Read::read(self, buf)?) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BufRead for &[u8] {
|
impl BufRead for &[u8] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fill_buf(&mut self) -> Result<&[u8]> { Ok(self) }
|
fn fill_buf(&mut self) -> Result<&[u8]> { Ok(self) }
|
||||||
|
@ -178,15 +172,6 @@ impl BufRead for &[u8] {
|
||||||
fn consume(&mut self, amount: usize) { *self = &self[amount..] }
|
fn consume(&mut self, amount: usize) { *self = &self[amount..] }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<R: std::io::Read> BufRead for std::io::BufReader<R> {
|
|
||||||
#[inline]
|
|
||||||
fn fill_buf(&mut self) -> Result<&[u8]> { Ok(std::io::BufRead::fill_buf(self)?) }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn consume(&mut self, amount: usize) { std::io::BufRead::consume(self, amount) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Wraps an in memory reader providing the `position` function.
|
/// Wraps an in memory reader providing the `position` function.
|
||||||
pub struct Cursor<T> {
|
pub struct Cursor<T> {
|
||||||
inner: T,
|
inner: T,
|
||||||
|
@ -301,15 +286,6 @@ impl<'a> Write for &'a mut [u8] {
|
||||||
fn flush(&mut self) -> Result<()> { Ok(()) }
|
fn flush(&mut self) -> Result<()> { Ok(()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl<W: std::io::Write> Write for std::io::BufWriter<W> {
|
|
||||||
#[inline]
|
|
||||||
fn write(&mut self, buf: &[u8]) -> Result<usize> { Ok(std::io::Write::write(self, buf)?) }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn flush(&mut self) -> Result<()> { Ok(std::io::Write::flush(self)?) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A sink to which all writes succeed. See [`std::io::Sink`] for more info.
|
/// A sink to which all writes succeed. See [`std::io::Sink`] for more info.
|
||||||
///
|
///
|
||||||
/// Created using `io::sink()`.
|
/// Created using `io::sink()`.
|
||||||
|
@ -326,18 +302,6 @@ impl Write for Sink {
|
||||||
fn flush(&mut self) -> Result<()> { Ok(()) }
|
fn flush(&mut self) -> Result<()> { Ok(()) }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl std::io::Write for Sink {
|
|
||||||
#[inline]
|
|
||||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> { Ok(buf.len()) }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn write_all(&mut self, _: &[u8]) -> std::io::Result<()> { Ok(()) }
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn flush(&mut self) -> std::io::Result<()> { Ok(()) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a sink to which all writes succeed. See [`std::io::sink`] for more info.
|
/// Returns a sink to which all writes succeed. See [`std::io::sink`] for more info.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn sink() -> Sink { Sink }
|
pub fn sink() -> Sink { Sink }
|
||||||
|
|
Loading…
Reference in New Issue