From 9fdca30f9e5946b4cf03712b3d9955a4098bd220 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Mon, 17 Oct 2022 00:31:27 +0100 Subject: [PATCH 1/5] Make `Bytes` pub --- src/decode.rs | 2 +- tests/test_misc.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/test_misc.rs diff --git a/src/decode.rs b/src/decode.rs index b9fb6f2..ce105a5 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -230,7 +230,7 @@ pub trait Reader: Sized { fn decode_image(&mut self, out: &mut [u8], channels: u8, src_channels: u8) -> Result<()>; } -struct Bytes<'a>(&'a [u8]); +pub struct Bytes<'a>(&'a [u8]); impl<'a> Bytes<'a> { #[inline] diff --git a/tests/test_misc.rs b/tests/test_misc.rs new file mode 100644 index 0000000..720adf4 --- /dev/null +++ b/tests/test_misc.rs @@ -0,0 +1,6 @@ +#[test] +fn test_new_encoder() { + // this used to fail due to `Bytes` not being `pub` + let arr = [0u8]; + let _ = qoi::Decoder::new(&arr[..]); +} \ No newline at end of file From bd009489522c2982d981e917bd148332076d286a Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Mon, 17 Oct 2022 00:34:11 +0100 Subject: [PATCH 2/5] Various clippy fixes --- src/decode.rs | 11 ++++++----- src/lib.rs | 3 ++- src/utils.rs | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/decode.rs b/src/decode.rs index ce105a5..019dac2 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -318,12 +318,13 @@ impl Decoder { /// Returns an immutable reference to the underlying reader. #[inline] - pub fn reader(&self) -> &R { + pub const fn reader(&self) -> &R { &self.reader } /// Consumes the decoder and returns the underlying reader back. #[inline] + #[allow(clippy::missing_const_for_fn)] pub fn into_reader(self) -> R { self.reader } @@ -343,7 +344,7 @@ impl Decoder { /// to decode RGB into RGBA (in which case the alpha channel will be set /// to 255), and vice versa (in which case the alpha channel will be ignored). #[inline] - pub fn with_channels(mut self, channels: Channels) -> Self { + pub const fn with_channels(mut self, channels: Channels) -> Self { self.channels = channels; self } @@ -352,13 +353,13 @@ impl Decoder { /// /// Note: this may differ from the number of channels specified in the header. #[inline] - pub fn channels(&self) -> Channels { + pub const fn channels(&self) -> Channels { self.channels } /// Returns the decoded image header. #[inline] - pub fn header(&self) -> &Header { + pub const fn header(&self) -> &Header { &self.header } @@ -366,7 +367,7 @@ impl Decoder { /// /// Can be used to pre-allocate the buffer to decode the image into. #[inline] - pub fn required_buf_len(&self) -> usize { + pub const fn required_buf_len(&self) -> usize { self.header.n_pixels().saturating_mul(self.channels.as_u8() as usize) } diff --git a/src/lib.rs b/src/lib.rs index 9ef6637..f77506b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -62,7 +62,8 @@ clippy::must_use_candidate, clippy::module_name_repetitions, clippy::cargo_common_metadata, - clippy::doc_markdown + clippy::doc_markdown, + clippy::return_self_not_must_use, )] #![cfg_attr(not(any(feature = "std", test)), no_std)] #[cfg(all(feature = "alloc", not(any(feature = "std", test))))] diff --git a/src/utils.rs b/src/utils.rs index 76ed92a..d0c37a6 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -84,7 +84,7 @@ pub struct GenericWriter { #[cfg(feature = "std")] impl GenericWriter { - pub fn new(writer: W) -> Self { + pub const fn new(writer: W) -> Self { Self { writer, n_written: 0 } } } From e30c034738a2fb576d2a4370e305c1b1d0e21214 Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Mon, 17 Oct 2022 00:42:28 +0100 Subject: [PATCH 3/5] Bump bytemuck dependency --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d1c8ec7..327a4d1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ std = [] # std mode (enabled by default) - provides access to `std::io`, reference = [] # follows reference encoder implementation precisely, but may be slightly slower [dependencies] -bytemuck = "1.7" +bytemuck = "1.12" [workspace] members = ["libqoi", "bench"] From 0e799be72d4eb5957edf72a4b6deacdfb4ec2e5f Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Mon, 17 Oct 2022 00:42:55 +0100 Subject: [PATCH 4/5] Bump MSRV to 1.60, set edition to 2021 --- .github/workflows/ci.yml | 2 +- Cargo.toml | 4 ++-- README.md | 3 +-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1839202..8f9f42a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - rust: [stable, beta, nightly, 1.51.0] # MSRV=1.51 + rust: [stable, beta, nightly, 1.61.0] # MSRV=1.61 steps: - uses: actions/checkout@v2 with: {submodules: true} diff --git a/Cargo.toml b/Cargo.toml index 327a4d1..4300672 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "qoi" version = "0.4.0" description = "VERY fast encoder/decoder for QOI (Quite Okay Image) format" authors = ["Ivan Smirnov "] -edition = "2018" +edition = "2021" readme = "README.md" license = "MIT/Apache-2.0" repository = "https://github.com/aldanor/qoi-rust" @@ -14,7 +14,7 @@ keywords = ["qoi", "graphics", "image", "encoding"] exclude = [ "assets/*", ] -rust-version = "1.51.0" +rust-version = "1.61.0" [features] default = ["std"] diff --git a/README.md b/README.md index a7de677..315d006 100644 --- a/README.md +++ b/README.md @@ -51,8 +51,7 @@ this library proved to be the fastest one by a noticeable margin. ### Rust version -The minimum required Rust version is 1.51.0 (any changes to this would be -considered to be a breaking change). +The minimum required Rust version for the latest crate version is 1.61.0. ### `no_std` From fe83d1b3eea80c83c0e4234b6a15ef237b8123ff Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Mon, 17 Oct 2022 00:51:38 +0100 Subject: [PATCH 5/5] Version bump to v0.4.1 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4300672..8417cc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "qoi" -version = "0.4.0" +version = "0.4.1" description = "VERY fast encoder/decoder for QOI (Quite Okay Image) format" authors = ["Ivan Smirnov "] edition = "2021"