This commit is contained in:
parent
a129a48b36
commit
49489aec64
6 changed files with 12 additions and 25 deletions
|
|
@ -126,8 +126,7 @@
|
|||
default = pkgs.mkShell rec {
|
||||
inputsFrom = [ self.packages.${system}.servicepoint ];
|
||||
packages = with pkgs; [
|
||||
(pkgs.symlinkJoin
|
||||
{
|
||||
(pkgs.symlinkJoin {
|
||||
name = "rust-toolchain";
|
||||
paths = with pkgs; [
|
||||
rustc
|
||||
|
|
@ -145,7 +144,7 @@
|
|||
];
|
||||
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}";
|
||||
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
|
||||
RUST_LOG="all";
|
||||
RUST_LOG = "all";
|
||||
RUST_BACKTRACE = "1";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ impl Bitmap {
|
|||
/// ```
|
||||
#[must_use]
|
||||
#[allow(clippy::iter_without_into_iter)]
|
||||
pub fn iter_mut(&mut self) -> IterMut<u8, Msb0> {
|
||||
pub fn iter_mut(&mut self) -> IterMut<'_, u8, Msb0> {
|
||||
self.bit_vec.iter_mut()
|
||||
}
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ impl Bitmap {
|
|||
&self,
|
||||
xs: impl RangeBounds<usize>,
|
||||
ys: impl RangeBounds<usize>,
|
||||
) -> Option<Window<bool, Self>> {
|
||||
) -> Option<Window<'_, bool, Self>> {
|
||||
let xs = absolute_bounds_to_abs_range(xs, self.width)?;
|
||||
let ys = absolute_bounds_to_abs_range(ys, self.height)?;
|
||||
Window::new(self, xs, ys)
|
||||
|
|
@ -198,7 +198,7 @@ impl Bitmap {
|
|||
&mut self,
|
||||
xs: impl RangeBounds<usize>,
|
||||
ys: impl RangeBounds<usize>,
|
||||
) -> Option<WindowMut<bool, Self>> {
|
||||
) -> Option<WindowMut<'_, bool, Self>> {
|
||||
let xs = absolute_bounds_to_abs_range(xs, self.width)?;
|
||||
let ys = absolute_bounds_to_abs_range(ys, self.height)?;
|
||||
WindowMut::new(self, xs, ys)
|
||||
|
|
@ -206,7 +206,6 @@ impl Bitmap {
|
|||
}
|
||||
|
||||
impl Grid<bool> for Bitmap {
|
||||
#[must_use]
|
||||
fn get_optional(&self, x: usize, y: usize) -> Option<bool> {
|
||||
let index = x + y * self.width;
|
||||
if self.is_in_bounds(x, y) {
|
||||
|
|
@ -216,12 +215,10 @@ impl Grid<bool> for Bitmap {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn width(&self) -> usize {
|
||||
self.width
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn height(&self) -> usize {
|
||||
self.height
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{CharGridMutExt, GridMut, TryLoadValueGridError, ValueGrid};
|
||||
use std::string::FromUtf8Error;
|
||||
use crate::{CharGridMutExt, GridMut, ValueGrid};
|
||||
|
||||
/// A grid containing UTF-8 characters.
|
||||
///
|
||||
|
|
|
|||
|
|
@ -69,12 +69,10 @@ pub trait CharGridMutExt {
|
|||
}
|
||||
|
||||
impl<G: Grid<char>> CharGridExt for G {
|
||||
#[must_use]
|
||||
fn get_col_str(&self, x: usize) -> Option<String> {
|
||||
Some(String::from_iter(self.get_col(x)?))
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn get_row_str(&self, y: usize) -> Option<String> {
|
||||
Some(String::from_iter(self.get_row(y)?))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,14 +144,14 @@ impl<T: Value> ValueGrid<T> {
|
|||
}
|
||||
|
||||
/// Iterate over all rows in [`ValueGrid`] top to bottom.
|
||||
pub fn iter_rows(&self) -> impl Iterator<Item = Iter<T>> + use<'_, T> {
|
||||
pub fn iter_rows(&self) -> impl Iterator<Item = Iter<'_, T>> {
|
||||
IterGridRows { grid: self, row: 0 }
|
||||
}
|
||||
|
||||
/// Returns an iterator that allows modifying each value.
|
||||
///
|
||||
/// The iterator yields all cells from top left to bottom right.
|
||||
pub fn iter_mut(&mut self) -> IterMut<T> {
|
||||
pub fn iter_mut(&mut self) -> IterMut<'_, T> {
|
||||
self.data.iter_mut()
|
||||
}
|
||||
|
||||
|
|
@ -242,7 +242,7 @@ impl<T: Value> ValueGrid<T> {
|
|||
&self,
|
||||
xs: impl RangeBounds<usize>,
|
||||
ys: impl RangeBounds<usize>,
|
||||
) -> Option<Window<T, Self>> {
|
||||
) -> Option<Window<'_, T, Self>> {
|
||||
let xs = absolute_bounds_to_abs_range(xs, self.width)?;
|
||||
let ys = absolute_bounds_to_abs_range(ys, self.height)?;
|
||||
Window::new(self, xs, ys)
|
||||
|
|
@ -255,7 +255,7 @@ impl<T: Value> ValueGrid<T> {
|
|||
&mut self,
|
||||
xs: impl RangeBounds<usize>,
|
||||
ys: impl RangeBounds<usize>,
|
||||
) -> Option<WindowMut<T, Self>> {
|
||||
) -> Option<WindowMut<'_, T, Self>> {
|
||||
let xs = absolute_bounds_to_abs_range(xs, self.width)?;
|
||||
let ys = absolute_bounds_to_abs_range(ys, self.height)?;
|
||||
WindowMut::new(self, xs, ys)
|
||||
|
|
@ -271,7 +271,6 @@ pub enum TryLoadValueGridError {
|
|||
}
|
||||
|
||||
impl<T: Value> Grid<T> for ValueGrid<T> {
|
||||
#[must_use]
|
||||
fn get_optional(&self, x: usize, y: usize) -> Option<T> {
|
||||
if self.is_in_bounds(x, y) {
|
||||
Some(self.data[x + y * self.width])
|
||||
|
|
@ -280,12 +279,10 @@ impl<T: Value> Grid<T> for ValueGrid<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn width(&self) -> usize {
|
||||
self.width
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn height(&self) -> usize {
|
||||
self.height
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ macro_rules! define_window {
|
|||
&self,
|
||||
xs: impl RangeBounds<usize>,
|
||||
ys: impl RangeBounds<usize>,
|
||||
) -> Option<Window<TElement, TGrid>> {
|
||||
) -> Option<Window<'_, TElement, TGrid>> {
|
||||
let xs = relative_bounds_to_abs_range(xs, self.xs.clone())?;
|
||||
let ys = relative_bounds_to_abs_range(ys, self.ys.clone())?;
|
||||
Window::new(self.grid, xs, ys)
|
||||
|
|
@ -115,7 +115,6 @@ macro_rules! define_window {
|
|||
impl<TElement: Copy, TGrid: Grid<TElement>> Grid<TElement>
|
||||
for $name<'_, TElement, TGrid>
|
||||
{
|
||||
#[must_use]
|
||||
fn get_optional(&self, x: usize, y: usize) -> Option<TElement> {
|
||||
if self.is_in_bounds(x, y) {
|
||||
Some(self.grid.get(self.xs.start + x, self.ys.start + y))
|
||||
|
|
@ -124,12 +123,10 @@ macro_rules! define_window {
|
|||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn width(&self) -> usize {
|
||||
self.xs.len()
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
fn height(&self) -> usize {
|
||||
self.ys.len()
|
||||
}
|
||||
|
|
@ -169,7 +166,7 @@ impl<TElement: Copy, TGrid: GridMut<TElement>> WindowMut<'_, TElement, TGrid> {
|
|||
&mut self,
|
||||
xs: impl RangeBounds<usize>,
|
||||
ys: impl RangeBounds<usize>,
|
||||
) -> Option<WindowMut<TElement, TGrid>> {
|
||||
) -> Option<WindowMut<'_, TElement, TGrid>> {
|
||||
let xs = relative_bounds_to_abs_range(xs, self.xs.clone())?;
|
||||
let ys = relative_bounds_to_abs_range(ys, self.ys.clone())?;
|
||||
WindowMut::new(self.grid, xs, ys)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue