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/qoi/src/utils.rs | 107 ------------------------------------------------ 1 file changed, 107 deletions(-) delete mode 100644 vendor/qoi/src/utils.rs (limited to 'vendor/qoi/src/utils.rs') diff --git a/vendor/qoi/src/utils.rs b/vendor/qoi/src/utils.rs deleted file mode 100644 index d0c37a6..0000000 --- a/vendor/qoi/src/utils.rs +++ /dev/null @@ -1,107 +0,0 @@ -#[cfg(feature = "std")] -use std::io::Write; - -use crate::error::Result; - -#[inline(always)] -#[cold] -pub const fn cold() {} - -#[inline(always)] -#[allow(unused)] -pub const fn likely(b: bool) -> bool { - if !b { - cold(); - } - b -} - -#[inline(always)] -pub const fn unlikely(b: bool) -> bool { - if b { - cold(); - } - b -} - -pub trait Writer: Sized { - fn write_one(self, v: u8) -> Result; - fn write_many(self, v: &[u8]) -> Result; - fn capacity(&self) -> usize; -} - -pub struct BytesMut<'a>(&'a mut [u8]); - -impl<'a> BytesMut<'a> { - pub fn new(buf: &'a mut [u8]) -> Self { - Self(buf) - } - - #[inline] - pub fn write_one(self, v: u8) -> Self { - if let Some((first, tail)) = self.0.split_first_mut() { - *first = v; - Self(tail) - } else { - unreachable!() - } - } - - #[inline] - pub fn write_many(self, v: &[u8]) -> Self { - if v.len() <= self.0.len() { - let (head, tail) = self.0.split_at_mut(v.len()); - head.copy_from_slice(v); - Self(tail) - } else { - unreachable!() - } - } -} - -impl<'a> Writer for BytesMut<'a> { - #[inline] - fn write_one(self, v: u8) -> Result { - Ok(BytesMut::write_one(self, v)) - } - - #[inline] - fn write_many(self, v: &[u8]) -> Result { - Ok(BytesMut::write_many(self, v)) - } - - #[inline] - fn capacity(&self) -> usize { - self.0.len() - } -} - -#[cfg(feature = "std")] -pub struct GenericWriter { - writer: W, - n_written: usize, -} - -#[cfg(feature = "std")] -impl GenericWriter { - pub const fn new(writer: W) -> Self { - Self { writer, n_written: 0 } - } -} - -#[cfg(feature = "std")] -impl Writer for GenericWriter { - fn write_one(mut self, v: u8) -> Result { - self.n_written += 1; - self.writer.write_all(&[v]).map(|_| self).map_err(Into::into) - } - - fn write_many(mut self, v: &[u8]) -> Result { - self.n_written += v.len(); - self.writer.write_all(v).map(|_| self).map_err(Into::into) - } - - fn capacity(&self) -> usize { - usize::MAX - self.n_written - } -} -- cgit v1.2.3