Skip to content

Commit

Permalink
Relax map_src argument bound to FnOnce (#2012) (#2028)
Browse files Browse the repository at this point in the history
* Relax `map_src` argument bound to `FnOnce`

Fixes #2009

* Release v0.8.9

Co-authored-by: Jack Wrenn <[email protected]>
  • Loading branch information
joshlf and jswrenn authored Nov 6, 2024
1 parent 4de8504 commit 3bcf6f3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ impl<Src, Dst: ?Sized> AlignmentError<Src, Dst> {
/// });
/// ```
#[inline]
pub fn map_src<NewSrc>(self, f: impl Fn(Src) -> NewSrc) -> AlignmentError<NewSrc, Dst> {
pub fn map_src<NewSrc>(self, f: impl FnOnce(Src) -> NewSrc) -> AlignmentError<NewSrc, Dst> {
AlignmentError { src: f(self.src), dst: SendSyncPhantomData::default() }
}

Expand Down Expand Up @@ -453,7 +453,7 @@ impl<Src, Dst: ?Sized> SizeError<Src, Dst> {
/// });
/// ```
#[inline]
pub fn map_src<NewSrc>(self, f: impl Fn(Src) -> NewSrc) -> SizeError<NewSrc, Dst> {
pub fn map_src<NewSrc>(self, f: impl FnOnce(Src) -> NewSrc) -> SizeError<NewSrc, Dst> {
SizeError { src: f(self.src), dst: SendSyncPhantomData::default() }
}

Expand Down Expand Up @@ -590,7 +590,7 @@ impl<Src, Dst: ?Sized + TryFromBytes> ValidityError<Src, Dst> {
/// });
/// ```
#[inline]
pub fn map_src<NewSrc>(self, f: impl Fn(Src) -> NewSrc) -> ValidityError<NewSrc, Dst> {
pub fn map_src<NewSrc>(self, f: impl FnOnce(Src) -> NewSrc) -> ValidityError<NewSrc, Dst> {
ValidityError { src: f(self.src), dst: SendSyncPhantomData::default() }
}

Expand Down Expand Up @@ -710,7 +710,7 @@ impl<Src, Dst: ?Sized> CastError<Src, Dst> {
/// });
/// ```
#[inline]
pub fn map_src<NewSrc>(self, f: impl Fn(Src) -> NewSrc) -> CastError<NewSrc, Dst> {
pub fn map_src<NewSrc>(self, f: impl FnOnce(Src) -> NewSrc) -> CastError<NewSrc, Dst> {
match self {
Self::Alignment(e) => CastError::Alignment(e.map_src(f)),
Self::Size(e) => CastError::Size(e.map_src(f)),
Expand Down Expand Up @@ -831,7 +831,7 @@ impl<Src, Dst: ?Sized + TryFromBytes> TryCastError<Src, Dst> {
/// });
/// ```
#[inline]
pub fn map_src<NewSrc>(self, f: impl Fn(Src) -> NewSrc) -> TryCastError<NewSrc, Dst> {
pub fn map_src<NewSrc>(self, f: impl FnOnce(Src) -> NewSrc) -> TryCastError<NewSrc, Dst> {
match self {
Self::Alignment(e) => TryCastError::Alignment(e.map_src(f)),
Self::Size(e) => TryCastError::Size(e.map_src(f)),
Expand Down Expand Up @@ -896,7 +896,7 @@ impl<Src, Dst: ?Sized + TryFromBytes> TryReadError<Src, Dst> {
/// });
/// ```
#[inline]
pub fn map_src<NewSrc>(self, f: impl Fn(Src) -> NewSrc) -> TryReadError<NewSrc, Dst> {
pub fn map_src<NewSrc>(self, f: impl FnOnce(Src) -> NewSrc) -> TryReadError<NewSrc, Dst> {
match self {
Self::Alignment(i) => match i {},
Self::Size(e) => TryReadError::Size(e.map_src(f)),
Expand Down

0 comments on commit 3bcf6f3

Please sign in to comment.