Skip to content

Commit

Permalink
Switch new_clip/new_animation closures to FnMut to allow mutations
Browse files Browse the repository at this point in the history
  • Loading branch information
merwaaan committed Jun 29, 2024
1 parent 2d16821 commit 78cb4c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl SpritesheetLibrary {
///
/// let stage = AnimationStage::from_clip(clip_id);
/// ```
pub fn new_clip<F: Fn(&mut AnimationClip)>(&mut self, builder: F) -> AnimationClipId {
pub fn new_clip<F: FnMut(&mut AnimationClip)>(&mut self, mut builder: F) -> AnimationClipId {
let id = AnimationClipId {
value: self.clips.len(),
};
Expand Down Expand Up @@ -231,7 +231,7 @@ impl SpritesheetLibrary {
/// ));
/// }
/// ```
pub fn new_animation<F: Fn(&mut Animation)>(&mut self, builder: F) -> AnimationId {
pub fn new_animation<F: FnMut(&mut Animation)>(&mut self, mut builder: F) -> AnimationId {
let id = AnimationId {
value: self.animations.len(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl AnimationStage {
/// }));
/// });
/// ```
pub fn new_with<F: Fn(&mut Self)>(clip_id: AnimationClipId, builder: F) -> Self {
pub fn new_with<F: FnMut(&mut Self)>(clip_id: AnimationClipId, mut builder: F) -> Self {
let mut stage = AnimationStage::from_clip(clip_id);

builder(&mut stage);
Expand Down
5 changes: 4 additions & 1 deletion tests/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ impl Context {
.clone()
}

pub fn update_sprite_animation<F: Fn(&mut SpritesheetAnimation) -> ()>(&mut self, builder: F) {
pub fn update_sprite_animation<F: FnMut(&mut SpritesheetAnimation) -> ()>(
&mut self,
mut builder: F,
) {
let mut sprite_animation = self
.app
.world
Expand Down

0 comments on commit 78cb4c3

Please sign in to comment.