From 3bcf6f388e15250ba02e564c1453a1bd06b0f5e0 Mon Sep 17 00:00:00 2001 From: Joshua Liebow-Feeser Date: Wed, 6 Nov 2024 09:16:00 -0800 Subject: [PATCH] Relax `map_src` argument bound to `FnOnce` (#2012) (#2028) * Relax `map_src` argument bound to `FnOnce` Fixes #2009 * Release v0.8.9 Co-authored-by: Jack Wrenn --- src/error.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/error.rs b/src/error.rs index 729102727d..39b2a864bf 100644 --- a/src/error.rs +++ b/src/error.rs @@ -298,7 +298,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() } } @@ -453,7 +453,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() } } @@ -590,7 +590,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() } } @@ -710,7 +710,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)), @@ -831,7 +831,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)), @@ -896,7 +896,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)),