From 1fb6365136cea52e7a541255d0e630f62d23926f Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Mon, 4 Nov 2024 11:41:29 -0500 Subject: [PATCH] Relax `map_src` argument bound to `FnOnce` (#2012) * Relax `map_src` argument bound to `FnOnce` Fixes #2009 * Release v0.8.9 --- Cargo.toml | 8 ++++---- src/error.rs | 12 ++++++------ zerocopy-derive/Cargo.toml | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 295fe6d50d..1ba523d50c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ [package] edition = "2021" name = "zerocopy" -version = "0.8.8" +version = "0.8.9" authors = ["Joshua Liebow-Feeser "] description = "Zerocopy makes zero-cost memory manipulation effortless. We write \"unsafe\" so you don't have to." categories = ["embedded", "encoding", "no-std::no-alloc", "parsing", "rust-patterns"] @@ -81,13 +81,13 @@ std = ["alloc"] __internal_use_only_features_that_work_on_stable = ["alloc", "derive", "simd", "std"] [dependencies] -zerocopy-derive = { version = "=0.8.8", path = "zerocopy-derive", optional = true } +zerocopy-derive = { version = "=0.8.9", path = "zerocopy-derive", optional = true } # The "associated proc macro pattern" ensures that the versions of zerocopy and # zerocopy-derive remain equal, even if the 'derive' feature isn't used. # See: https://github.com/matklad/macro-dep-test [target.'cfg(any())'.dependencies] -zerocopy-derive = { version = "=0.8.8", path = "zerocopy-derive" } +zerocopy-derive = { version = "=0.8.9", path = "zerocopy-derive" } [dev-dependencies] itertools = "0.11" @@ -101,6 +101,6 @@ testutil = { path = "testutil" } # CI test failures. trybuild = { version = "=1.0.89", features = ["diff"] } # In tests, unlike in production, zerocopy-derive is not optional -zerocopy-derive = { version = "=0.8.8", path = "zerocopy-derive" } +zerocopy-derive = { version = "=0.8.9", path = "zerocopy-derive" } # TODO(#381) Remove this dependency once we have our own layout gadgets. elain = "0.3.0" diff --git a/src/error.rs b/src/error.rs index aa4b34a3e8..ad3b25386f 100644 --- a/src/error.rs +++ b/src/error.rs @@ -299,7 +299,7 @@ impl AlignmentError { /// }); /// ``` #[inline] - pub fn map_src(self, f: impl Fn(Src) -> NewSrc) -> AlignmentError { + pub fn map_src(self, f: impl FnOnce(Src) -> NewSrc) -> AlignmentError { AlignmentError { src: f(self.src), dst: SendSyncPhantomData::default() } } @@ -455,7 +455,7 @@ impl SizeError { /// }); /// ``` #[inline] - pub fn map_src(self, f: impl Fn(Src) -> NewSrc) -> SizeError { + pub fn map_src(self, f: impl FnOnce(Src) -> NewSrc) -> SizeError { SizeError { src: f(self.src), dst: SendSyncPhantomData::default() } } @@ -593,7 +593,7 @@ impl ValidityError { /// }); /// ``` #[inline] - pub fn map_src(self, f: impl Fn(Src) -> NewSrc) -> ValidityError { + pub fn map_src(self, f: impl FnOnce(Src) -> NewSrc) -> ValidityError { ValidityError { src: f(self.src), dst: SendSyncPhantomData::default() } } @@ -714,7 +714,7 @@ impl CastError { /// }); /// ``` #[inline] - pub fn map_src(self, f: impl Fn(Src) -> NewSrc) -> CastError { + pub fn map_src(self, f: impl FnOnce(Src) -> NewSrc) -> CastError { match self { Self::Alignment(e) => CastError::Alignment(e.map_src(f)), Self::Size(e) => CastError::Size(e.map_src(f)), @@ -835,7 +835,7 @@ impl TryCastError { /// }); /// ``` #[inline] - pub fn map_src(self, f: impl Fn(Src) -> NewSrc) -> TryCastError { + pub fn map_src(self, f: impl FnOnce(Src) -> NewSrc) -> TryCastError { match self { Self::Alignment(e) => TryCastError::Alignment(e.map_src(f)), Self::Size(e) => TryCastError::Size(e.map_src(f)), @@ -900,7 +900,7 @@ impl TryReadError { /// }); /// ``` #[inline] - pub fn map_src(self, f: impl Fn(Src) -> NewSrc) -> TryReadError { + pub fn map_src(self, f: impl FnOnce(Src) -> NewSrc) -> TryReadError { match self { Self::Alignment(i) => match i {}, Self::Size(e) => TryReadError::Size(e.map_src(f)), diff --git a/zerocopy-derive/Cargo.toml b/zerocopy-derive/Cargo.toml index 839158a5a7..cf0f7024e8 100644 --- a/zerocopy-derive/Cargo.toml +++ b/zerocopy-derive/Cargo.toml @@ -9,7 +9,7 @@ [package] edition = "2021" name = "zerocopy-derive" -version = "0.8.8" +version = "0.8.9" authors = ["Joshua Liebow-Feeser "] description = "Custom derive for traits from the zerocopy crate" license = "BSD-2-Clause OR Apache-2.0 OR MIT"