From a990de90fe41456a23e58bd087d2f107d321f3a1 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Fri, 19 Jul 2024 16:37:58 +0400 Subject: Deleted vendor folder --- vendor/anstream/src/fmt.rs | 54 ---------------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 vendor/anstream/src/fmt.rs (limited to 'vendor/anstream/src/fmt.rs') diff --git a/vendor/anstream/src/fmt.rs b/vendor/anstream/src/fmt.rs deleted file mode 100644 index e673c26..0000000 --- a/vendor/anstream/src/fmt.rs +++ /dev/null @@ -1,54 +0,0 @@ -/// A shim which allows a [`std::io::Write`] to be implemented in terms of a [`std::fmt::Write`] -/// -/// This saves off I/O errors. instead of discarding them -pub(crate) struct Adapter -where - W: FnMut(&[u8]) -> std::io::Result<()>, -{ - writer: W, - error: std::io::Result<()>, -} - -impl Adapter -where - W: FnMut(&[u8]) -> std::io::Result<()>, -{ - pub(crate) fn new(writer: W) -> Self { - Adapter { - writer, - error: Ok(()), - } - } - - pub(crate) fn write_fmt(mut self, fmt: std::fmt::Arguments<'_>) -> std::io::Result<()> { - match std::fmt::write(&mut self, fmt) { - Ok(()) => Ok(()), - Err(..) => { - // check if the error came from the underlying `Write` or not - if self.error.is_err() { - self.error - } else { - Err(std::io::Error::new( - std::io::ErrorKind::Other, - "formatter error", - )) - } - } - } - } -} - -impl std::fmt::Write for Adapter -where - W: FnMut(&[u8]) -> std::io::Result<()>, -{ - fn write_str(&mut self, s: &str) -> std::fmt::Result { - match (self.writer)(s.as_bytes()) { - Ok(()) => Ok(()), - Err(e) => { - self.error = Err(e); - Err(std::fmt::Error) - } - } - } -} -- cgit v1.2.3