From 93df36d3b53edadae6e356e8b9dc0a5af28dd328 Mon Sep 17 00:00:00 2001 From: Timm Ortloff Date: Mon, 6 Apr 2026 18:52:56 +0200 Subject: [PATCH 1/2] Bump `memchr` to `2.8.0` --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 7298475..8aed2b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,4 +14,4 @@ default = [] read_initializer = [] [dependencies] -memchr = "2.4.1" +memchr = "2.8.0" From b16896bb89d6173ef14c23649d17800ba615a235 Mon Sep 17 00:00:00 2001 From: Timm Ortloff Date: Mon, 6 Apr 2026 18:53:09 +0200 Subject: [PATCH 2/2] Set rust edition to `2024` --- Cargo.toml | 2 +- src/io_helpers.rs | 32 +++++++++++++++++--------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8aed2b9..9ed94c0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "rev_buf_reader" version = "0.3.0" authors = ["André Vicente Milack "] -edition = "2021" +edition = "2024" description = "Crate that provides a buffered reader capable of reading chunks of bytes of a data stream in reverse order. Its implementation is an adapted copy of BufReader from the nightly std::io." repository = "https://github.com/andre-vm/rev_buf_reader" exclude = ["base/*"] diff --git a/src/io_helpers.rs b/src/io_helpers.rs index 169dde9..0c793f3 100644 --- a/src/io_helpers.rs +++ b/src/io_helpers.rs @@ -40,21 +40,23 @@ pub(crate) unsafe fn append_to_string(buf: &mut String, f: F) -> io::Result) -> io::Result, { - let mut g = Guard { - len: buf.len(), - buf: buf.as_mut_vec(), - }; - let ret = f(g.buf); - if str::from_utf8(&g.buf[g.len..]).is_err() { - ret.and_then(|_| { - Err(io::Error::new( - io::ErrorKind::InvalidData, - "stream did not contain valid UTF-8", - )) - }) - } else { - g.len = g.buf.len(); - ret + unsafe { + let mut g = Guard { + len: buf.len(), + buf: buf.as_mut_vec(), + }; + let ret = f(g.buf); + if str::from_utf8(&g.buf[g.len..]).is_err() { + ret.and_then(|_| { + Err(io::Error::new( + io::ErrorKind::InvalidData, + "stream did not contain valid UTF-8", + )) + }) + } else { + g.len = g.buf.len(); + ret + } } }