Use FnMut instead of Fn

main
copygirl 4 days ago
parent 8ce5513e77
commit 54abd3e61c
  1. 2
      src/bloxel/storage/bloxel_array.rs
  2. 2
      src/bloxel/storage/bloxel_store.rs

@ -23,7 +23,7 @@ impl<T: Copy> BloxelArray<T> {
Self { size, data }
}
pub fn from_fn(size: USize3, f: impl Fn(IVec3) -> T) -> Self {
pub fn from_fn(size: USize3, mut f: impl FnMut(IVec3) -> T) -> Self {
let f = |(x, y, z)| f(IVec3::new(x as i32, y as i32, z as i32));
let data = Array3::from_shape_fn(size, f);
Self { size, data }

@ -12,7 +12,7 @@ pub trait BloxelStore<T: Copy> {
pub trait BloxelStoreMut<T: Copy>: BloxelStore<T> {
fn set(&mut self, pos: IVec3, value: T) -> Result<T, ()>;
fn update(&mut self, f: impl Fn(IVec3, T) -> T) {
fn update(&mut self, mut f: impl FnMut(IVec3, T) -> T) {
let (w, h, d) = self.size().into();
for prod in Hom3FCartProd::new(0..w, 0..h, 0..d) {
let pos = UVec3::from(prod).as_ivec3();

Loading…
Cancel
Save