From ab70ce7f539814a15636d6fc10c487cdbe7ffb05 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 27 Mar 2025 14:45:14 -0400 Subject: [PATCH] Grid: move around unsafe block --- src/grid.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/grid.rs b/src/grid.rs index fb3840b..12e3f0c 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -140,13 +140,12 @@ where let bufs: Vec<_> = grids.iter().map(|grid| &grid.buf.buf).collect(); // We mutate grid buffers and read grid data. We use unsafe because we need shared/unique borrows on different fields of the same Grid struct. - bufs.iter().enumerate().for_each(|(i, buf)| unsafe { + bufs.iter().enumerate().for_each(|(i, buf)| { let buf_ptr = *buf as *const Vec as *mut Vec; - buf_ptr.as_mut().unwrap().fill(0.0); + unsafe { buf_ptr.as_mut() }.unwrap().fill(0.0); datas.iter().enumerate().for_each(|(j, other)| { let multiplier = attraction_table[i].as_ref()[j]; - buf_ptr - .as_mut() + unsafe { buf_ptr.as_mut() } .unwrap() .iter_mut() .zip(*other)