use std::{num::NonZeroUsize, ops::Range}; use crate::vector_grid::VectorGrid; impl VectorGrid { pub(crate) fn cut_columns(&mut self, column_range: Range) { if column_range.end > self.width().get() { panic!("Range of columns to cut goes beyond the maps width") } let cut_width = column_range.end - column_range.start; let mut i = column_range.start; self.width = NonZeroUsize::new(self.width.get() - cut_width).unwrap(); while i < self.items.len() { self.items .splice(i..(i + cut_width).min(self.items.len()), []); i += self.width().get(); } } }