Skip to content

Commit

Permalink
Change bound in map/apply from Fn to FnMut (#136)
Browse files Browse the repository at this point in the history
* Change map/apply from Fn to FnMut

* Update changelog
  • Loading branch information
sjb3d authored Sep 10, 2021
1 parent 4e7ff46 commit 42ac370
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

- Add methods to scale `Rotor3`
- Implement `Neg` for all `IVec` types
- Relax bound in `map` and `apply` from `Fn` to `FnMut`

## 0.8.1

Expand Down
24 changes: 12 additions & 12 deletions src/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ macro_rules! ivec2s {
}

#[inline]
pub fn map<F>(&self, f: F) -> Self
where F: Fn($t) -> $t
pub fn map<F>(&self, mut f: F) -> Self
where F: FnMut($t) -> $t
{
$n::new(
f(self.x),
Expand All @@ -144,8 +144,8 @@ macro_rules! ivec2s {
}

#[inline]
pub fn apply<F>(&mut self, f: F)
where F: Fn($t) -> $t
pub fn apply<F>(&mut self, mut f: F)
where F: FnMut($t) -> $t
{
self.x = f(self.x);
self.y = f(self.y);
Expand Down Expand Up @@ -577,8 +577,8 @@ macro_rules! ivec3s {
}

#[inline]
pub fn map<F>(&self, f: F) -> Self
where F: Fn($t) -> $t
pub fn map<F>(&self, mut f: F) -> Self
where F: FnMut($t) -> $t
{
$n::new(
f(self.x),
Expand All @@ -588,8 +588,8 @@ macro_rules! ivec3s {
}

#[inline]
pub fn apply<F>(&mut self, f: F)
where F: Fn($t) -> $t
pub fn apply<F>(&mut self, mut f: F)
where F: FnMut($t) -> $t
{
self.x = f(self.x);
self.y = f(self.y);
Expand Down Expand Up @@ -1001,8 +1001,8 @@ macro_rules! ivec4s {
}

#[inline]
pub fn map<F>(&self, f: F) -> Self
where F: Fn($t) -> $t
pub fn map<F>(&self, mut f: F) -> Self
where F: FnMut($t) -> $t
{
$n::new(
f(self.x),
Expand All @@ -1013,8 +1013,8 @@ macro_rules! ivec4s {
}

#[inline]
pub fn apply<F>(&mut self, f: F)
where F: Fn($t) -> $t
pub fn apply<F>(&mut self, mut f: F)
where F: FnMut($t) -> $t
{
self.x = f(self.x);
self.y = f(self.y);
Expand Down
8 changes: 4 additions & 4 deletions src/vec/vec2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ macro_rules! vec2s {
}

#[inline]
pub fn map<F>(&self, f: F) -> Self
where F: Fn($t) -> $t
pub fn map<F>(&self, mut f: F) -> Self
where F: FnMut($t) -> $t
{
$n::new(
f(self.x),
Expand All @@ -186,8 +186,8 @@ macro_rules! vec2s {
}

#[inline]
pub fn apply<F>(&mut self, f: F)
where F: Fn($t) -> $t
pub fn apply<F>(&mut self, mut f: F)
where F: FnMut($t) -> $t
{
self.x = f(self.x);
self.y = f(self.y);
Expand Down
8 changes: 4 additions & 4 deletions src/vec/vec3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ macro_rules! vec3s {
}

#[inline]
pub fn map<F>(&self, f: F) -> Self
where F: Fn($t) -> $t
pub fn map<F>(&self, mut f: F) -> Self
where F: FnMut($t) -> $t
{
$n::new(
f(self.x),
Expand All @@ -235,8 +235,8 @@ macro_rules! vec3s {
}

#[inline]
pub fn apply<F>(&mut self, f: F)
where F: Fn($t) -> $t
pub fn apply<F>(&mut self, mut f: F)
where F: FnMut($t) -> $t
{
self.x = f(self.x);
self.y = f(self.y);
Expand Down
8 changes: 4 additions & 4 deletions src/vec/vec4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ macro_rules! vec4s {
}

#[inline]
pub fn map<F>(&self, f: F) -> Self
where F: Fn($t) -> $t
pub fn map<F>(&self, mut f: F) -> Self
where F: FnMut($t) -> $t
{
$n::new(
f(self.x),
Expand All @@ -168,8 +168,8 @@ macro_rules! vec4s {
}

#[inline]
pub fn apply<F>(&mut self, f: F)
where F: Fn($t) -> $t
pub fn apply<F>(&mut self, mut f: F)
where F: FnMut($t) -> $t
{
self.x = f(self.x);
self.y = f(self.y);
Expand Down

0 comments on commit 42ac370

Please sign in to comment.