it only worked for methods explicitly mentioned
This commit is contained in:
		
							parent
							
								
									77c4c38cfb
								
							
						
					
					
						commit
						a129a48b36
					
				
					 11 changed files with 50 additions and 59 deletions
				
			
		
							
								
								
									
										14
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										14
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -201,17 +201,6 @@ version = "0.5.0"
 | 
				
			||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
					source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
				
			||||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
 | 
					checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					 | 
				
			||||||
name = "inherent"
 | 
					 | 
				
			||||||
version = "1.0.12"
 | 
					 | 
				
			||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
					 | 
				
			||||||
checksum = "6c38228f24186d9cc68c729accb4d413be9eaed6ad07ff79e0270d9e56f3de13"
 | 
					 | 
				
			||||||
dependencies = [
 | 
					 | 
				
			||||||
 "proc-macro2",
 | 
					 | 
				
			||||||
 "quote",
 | 
					 | 
				
			||||||
 "syn",
 | 
					 | 
				
			||||||
]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "is_terminal_polyfill"
 | 
					name = "is_terminal_polyfill"
 | 
				
			||||||
version = "1.70.1"
 | 
					version = "1.70.1"
 | 
				
			||||||
| 
						 | 
					@ -347,13 +336,12 @@ dependencies = [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "servicepoint"
 | 
					name = "servicepoint"
 | 
				
			||||||
version = "0.15.2"
 | 
					version = "0.16.0"
 | 
				
			||||||
dependencies = [
 | 
					dependencies = [
 | 
				
			||||||
 "bitvec",
 | 
					 "bitvec",
 | 
				
			||||||
 "bzip2",
 | 
					 "bzip2",
 | 
				
			||||||
 "clap",
 | 
					 "clap",
 | 
				
			||||||
 "flate2",
 | 
					 "flate2",
 | 
				
			||||||
 "inherent",
 | 
					 | 
				
			||||||
 "log",
 | 
					 "log",
 | 
				
			||||||
 "once_cell",
 | 
					 "once_cell",
 | 
				
			||||||
 "rand",
 | 
					 "rand",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
[package]
 | 
					[package]
 | 
				
			||||||
name = "servicepoint"
 | 
					name = "servicepoint"
 | 
				
			||||||
version = "0.15.2"
 | 
					version = "0.16.0"
 | 
				
			||||||
publish = true
 | 
					publish = true
 | 
				
			||||||
edition = "2021"
 | 
					edition = "2021"
 | 
				
			||||||
license = "GPL-3.0-or-later"
 | 
					license = "GPL-3.0-or-later"
 | 
				
			||||||
| 
						 | 
					@ -24,7 +24,6 @@ rust-lzma = { version = "0.6", optional = true }
 | 
				
			||||||
rand = { version = "0.9", optional = true }
 | 
					rand = { version = "0.9", optional = true }
 | 
				
			||||||
once_cell = { version = "1.20", optional = true }
 | 
					once_cell = { version = "1.20", optional = true }
 | 
				
			||||||
thiserror = "2.0"
 | 
					thiserror = "2.0"
 | 
				
			||||||
inherent = "1.0"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
[features]
 | 
					[features]
 | 
				
			||||||
default = ["compression_lzma", "cp437"]
 | 
					default = ["compression_lzma", "cp437"]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,7 @@
 | 
				
			||||||
use clap::Parser;
 | 
					use clap::Parser;
 | 
				
			||||||
use servicepoint::{
 | 
					use servicepoint::{
 | 
				
			||||||
    Bitmap, BitmapCommand, Brightness, BrightnessGrid, BrightnessGridCommand,
 | 
					    Bitmap, BitmapCommand, Brightness, BrightnessGrid, BrightnessGridCommand,
 | 
				
			||||||
    DataRef, UdpSocketExt, TILE_HEIGHT, TILE_WIDTH,
 | 
					    DataRef, GridMut, UdpSocketExt, TILE_HEIGHT, TILE_WIDTH,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::net::UdpSocket;
 | 
					use std::net::UdpSocket;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ use clap::Parser;
 | 
				
			||||||
use rand::Rng;
 | 
					use rand::Rng;
 | 
				
			||||||
use servicepoint::{
 | 
					use servicepoint::{
 | 
				
			||||||
    Bitmap, BitmapCommand, Brightness, BrightnessGrid, BrightnessGridCommand,
 | 
					    Bitmap, BitmapCommand, Brightness, BrightnessGrid, BrightnessGridCommand,
 | 
				
			||||||
    GlobalBrightnessCommand, Grid, GridMut, Origin, UdpSocketExt, TILE_HEIGHT,
 | 
					    GlobalBrightnessCommand, GridMut, Origin, UdpSocketExt, TILE_HEIGHT,
 | 
				
			||||||
    TILE_WIDTH,
 | 
					    TILE_WIDTH,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::{net::UdpSocket, time::Duration};
 | 
					use std::{net::UdpSocket, time::Duration};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,7 @@ use crate::{
 | 
				
			||||||
    command_code::{CommandCode, InvalidCommandCodeError},
 | 
					    command_code::{CommandCode, InvalidCommandCodeError},
 | 
				
			||||||
    commands::errors::{TryFromPacketError, TryIntoPacketError},
 | 
					    commands::errors::{TryFromPacketError, TryIntoPacketError},
 | 
				
			||||||
    compression::{compress, decompress, CompressionError},
 | 
					    compression::{compress, decompress, CompressionError},
 | 
				
			||||||
    Bitmap, CompressionCode, DataRef, Header, Origin, Packet, Pixels,
 | 
					    Bitmap, CompressionCode, DataRef, Grid, Header, Origin, Packet, Pixels,
 | 
				
			||||||
    TypedCommand, TILE_SIZE,
 | 
					    TypedCommand, TILE_SIZE,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -183,6 +183,7 @@ mod tests {
 | 
				
			||||||
    use super::*;
 | 
					    use super::*;
 | 
				
			||||||
    use crate::{
 | 
					    use crate::{
 | 
				
			||||||
        command_code::CommandCode, commands::tests::TestImplementsCommand,
 | 
					        command_code::CommandCode, commands::tests::TestImplementsCommand,
 | 
				
			||||||
 | 
					        GridMut,
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    impl TestImplementsCommand for BitmapCommand {}
 | 
					    impl TestImplementsCommand for BitmapCommand {}
 | 
				
			||||||
| 
						 | 
					@ -325,4 +326,17 @@ mod tests {
 | 
				
			||||||
            );
 | 
					            );
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #[test]
 | 
				
			||||||
 | 
					    fn invalid_y() {
 | 
				
			||||||
 | 
					        let command = BitmapCommand {
 | 
				
			||||||
 | 
					            bitmap: Bitmap::new(8, 3).unwrap(),
 | 
				
			||||||
 | 
					            origin: Origin::new(4, u16::MAX as usize + 1),
 | 
				
			||||||
 | 
					            compression: CompressionCode::Uncompressed,
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        assert!(matches!(
 | 
				
			||||||
 | 
					            Packet::try_from(command),
 | 
				
			||||||
 | 
					            Err(TryIntoPacketError::ConversionError(_)),
 | 
				
			||||||
 | 
					        ))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -414,4 +414,18 @@ mod tests {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    #[test]
 | 
				
			||||||
 | 
					    fn invalid_offset() {
 | 
				
			||||||
 | 
					        let command = BitVecCommand {
 | 
				
			||||||
 | 
					            bitvec: DisplayBitVec::repeat(false, 16),
 | 
				
			||||||
 | 
					            offset: u16::MAX as usize + 1,
 | 
				
			||||||
 | 
					            operation: BinaryOperation::Or,
 | 
				
			||||||
 | 
					            compression: CompressionCode::Uncompressed,
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					        assert!(matches!(
 | 
				
			||||||
 | 
					            Packet::try_from(command),
 | 
				
			||||||
 | 
					            Err(TryIntoPacketError::ConversionError(_)),
 | 
				
			||||||
 | 
					        ))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,7 +3,6 @@ use crate::{
 | 
				
			||||||
    GridMut, Payload, ValueGrid, Window, WindowMut, PIXEL_HEIGHT, PIXEL_WIDTH,
 | 
					    GridMut, Payload, ValueGrid, Window, WindowMut, PIXEL_HEIGHT, PIXEL_WIDTH,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use ::bitvec::{order::Msb0, prelude::BitSlice, slice::IterMut};
 | 
					use ::bitvec::{order::Msb0, prelude::BitSlice, slice::IterMut};
 | 
				
			||||||
use inherent::inherent;
 | 
					 | 
				
			||||||
use std::ops::RangeBounds;
 | 
					use std::ops::RangeBounds;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// A fixed-size 2D grid of booleans.
 | 
					/// A fixed-size 2D grid of booleans.
 | 
				
			||||||
| 
						 | 
					@ -206,11 +205,9 @@ impl Bitmap {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[inherent]
 | 
					 | 
				
			||||||
impl Grid<bool> for Bitmap {
 | 
					impl Grid<bool> for Bitmap {
 | 
				
			||||||
    #[must_use]
 | 
					    #[must_use]
 | 
				
			||||||
    #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					    fn get_optional(&self, x: usize, y: usize) -> Option<bool> {
 | 
				
			||||||
    pub fn get_optional(&self, x: usize, y: usize) -> Option<bool> {
 | 
					 | 
				
			||||||
        let index = x + y * self.width;
 | 
					        let index = x + y * self.width;
 | 
				
			||||||
        if self.is_in_bounds(x, y) {
 | 
					        if self.is_in_bounds(x, y) {
 | 
				
			||||||
            Some(self.bit_vec[index])
 | 
					            Some(self.bit_vec[index])
 | 
				
			||||||
| 
						 | 
					@ -220,17 +217,16 @@ impl Grid<bool> for Bitmap {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[must_use]
 | 
					    #[must_use]
 | 
				
			||||||
    pub fn width(&self) -> usize {
 | 
					    fn width(&self) -> usize {
 | 
				
			||||||
        self.width
 | 
					        self.width
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[must_use]
 | 
					    #[must_use]
 | 
				
			||||||
    pub fn height(&self) -> usize {
 | 
					    fn height(&self) -> usize {
 | 
				
			||||||
        self.height
 | 
					        self.height
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[inherent]
 | 
					 | 
				
			||||||
impl GridMut<bool> for Bitmap {
 | 
					impl GridMut<bool> for Bitmap {
 | 
				
			||||||
    /// Sets the value of the specified position in the [Bitmap].
 | 
					    /// Sets the value of the specified position in the [Bitmap].
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
| 
						 | 
					@ -244,8 +240,7 @@ impl GridMut<bool> for Bitmap {
 | 
				
			||||||
    /// # Panics
 | 
					    /// # Panics
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// When accessing `x` or `y` out of bounds.
 | 
					    /// When accessing `x` or `y` out of bounds.
 | 
				
			||||||
    #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					    fn set_optional(&mut self, x: usize, y: usize, value: bool) -> bool {
 | 
				
			||||||
    pub fn set_optional(&mut self, x: usize, y: usize, value: bool) -> bool {
 | 
					 | 
				
			||||||
        if self.is_in_bounds(x, y) {
 | 
					        if self.is_in_bounds(x, y) {
 | 
				
			||||||
            self.bit_vec.set(x + y * self.width, value);
 | 
					            self.bit_vec.set(x + y * self.width, value);
 | 
				
			||||||
            true
 | 
					            true
 | 
				
			||||||
| 
						 | 
					@ -260,8 +255,7 @@ impl GridMut<bool> for Bitmap {
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// - `this`: instance to write to
 | 
					    /// - `this`: instance to write to
 | 
				
			||||||
    /// - `value`: the value to set all pixels to
 | 
					    /// - `value`: the value to set all pixels to
 | 
				
			||||||
    #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					    fn fill(&mut self, value: bool) {
 | 
				
			||||||
    pub fn fill(&mut self, value: bool) {
 | 
					 | 
				
			||||||
        self.bit_vec.fill(value);
 | 
					        self.bit_vec.fill(value);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
use crate::{Brightness, ByteGrid, ValueGrid};
 | 
					use crate::{Brightness, ByteGrid, Grid, ValueGrid};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/// A grid containing brightness values.
 | 
					/// A grid containing brightness values.
 | 
				
			||||||
///
 | 
					///
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -146,6 +146,7 @@ impl From<CharGrid> for Vec<u8> {
 | 
				
			||||||
#[cfg(test)]
 | 
					#[cfg(test)]
 | 
				
			||||||
mod test {
 | 
					mod test {
 | 
				
			||||||
    use super::*;
 | 
					    use super::*;
 | 
				
			||||||
 | 
					    use crate::Grid;
 | 
				
			||||||
    #[test]
 | 
					    #[test]
 | 
				
			||||||
    fn str_to_char_grid() {
 | 
					    fn str_to_char_grid() {
 | 
				
			||||||
        // conversion with .to_string() covers one more line
 | 
					        // conversion with .to_string() covers one more line
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,6 @@ use crate::{
 | 
				
			||||||
    containers::absolute_bounds_to_abs_range, DataRef, Grid, GridMut, Window,
 | 
					    containers::absolute_bounds_to_abs_range, DataRef, Grid, GridMut, Window,
 | 
				
			||||||
    WindowMut,
 | 
					    WindowMut,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use inherent::inherent;
 | 
					 | 
				
			||||||
use std::{
 | 
					use std::{
 | 
				
			||||||
    fmt::Debug,
 | 
					    fmt::Debug,
 | 
				
			||||||
    ops::RangeBounds,
 | 
					    ops::RangeBounds,
 | 
				
			||||||
| 
						 | 
					@ -271,11 +270,9 @@ pub enum TryLoadValueGridError {
 | 
				
			||||||
    InvalidDimensions,
 | 
					    InvalidDimensions,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[inherent]
 | 
					 | 
				
			||||||
impl<T: Value> Grid<T> for ValueGrid<T> {
 | 
					impl<T: Value> Grid<T> for ValueGrid<T> {
 | 
				
			||||||
    #[must_use]
 | 
					    #[must_use]
 | 
				
			||||||
    #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					    fn get_optional(&self, x: usize, y: usize) -> Option<T> {
 | 
				
			||||||
    pub fn get_optional(&self, x: usize, y: usize) -> Option<T> {
 | 
					 | 
				
			||||||
        if self.is_in_bounds(x, y) {
 | 
					        if self.is_in_bounds(x, y) {
 | 
				
			||||||
            Some(self.data[x + y * self.width])
 | 
					            Some(self.data[x + y * self.width])
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
| 
						 | 
					@ -284,17 +281,16 @@ impl<T: Value> Grid<T> for ValueGrid<T> {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[must_use]
 | 
					    #[must_use]
 | 
				
			||||||
    pub fn width(&self) -> usize {
 | 
					    fn width(&self) -> usize {
 | 
				
			||||||
        self.width
 | 
					        self.width
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[must_use]
 | 
					    #[must_use]
 | 
				
			||||||
    pub fn height(&self) -> usize {
 | 
					    fn height(&self) -> usize {
 | 
				
			||||||
        self.height
 | 
					        self.height
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[inherent]
 | 
					 | 
				
			||||||
impl<T: Value> GridMut<T> for ValueGrid<T> {
 | 
					impl<T: Value> GridMut<T> for ValueGrid<T> {
 | 
				
			||||||
    /// Sets the value of the cell at the specified position in the grid.
 | 
					    /// Sets the value of the cell at the specified position in the grid.
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
| 
						 | 
					@ -306,8 +302,7 @@ impl<T: Value> GridMut<T> for ValueGrid<T> {
 | 
				
			||||||
    /// # Panics
 | 
					    /// # Panics
 | 
				
			||||||
    ///
 | 
					    ///
 | 
				
			||||||
    /// When accessing `x` or `y` out of bounds.
 | 
					    /// When accessing `x` or `y` out of bounds.
 | 
				
			||||||
    #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					    fn set_optional(&mut self, x: usize, y: usize, value: T) -> bool {
 | 
				
			||||||
    pub fn set_optional(&mut self, x: usize, y: usize, value: T) -> bool {
 | 
					 | 
				
			||||||
        if self.is_in_bounds(x, y) {
 | 
					        if self.is_in_bounds(x, y) {
 | 
				
			||||||
            self.data[x + y * self.width] = value;
 | 
					            self.data[x + y * self.width] = value;
 | 
				
			||||||
            true
 | 
					            true
 | 
				
			||||||
| 
						 | 
					@ -316,8 +311,7 @@ impl<T: Value> GridMut<T> for ValueGrid<T> {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					    fn fill(&mut self, value: T) {
 | 
				
			||||||
    pub fn fill(&mut self, value: T) {
 | 
					 | 
				
			||||||
        self.data.fill(value);
 | 
					        self.data.fill(value);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +26,6 @@ macro_rules! define_window {
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            /// Create a new window into `grid`.
 | 
					            /// Create a new window into `grid`.
 | 
				
			||||||
            #[must_use]
 | 
					            #[must_use]
 | 
				
			||||||
            #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					 | 
				
			||||||
            pub fn new(
 | 
					            pub fn new(
 | 
				
			||||||
                grid: $grid,
 | 
					                grid: $grid,
 | 
				
			||||||
                xs: impl RangeBounds<usize>,
 | 
					                xs: impl RangeBounds<usize>,
 | 
				
			||||||
| 
						 | 
					@ -113,13 +112,11 @@ macro_rules! define_window {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        #[inherent::inherent]
 | 
					 | 
				
			||||||
        impl<TElement: Copy, TGrid: Grid<TElement>> Grid<TElement>
 | 
					        impl<TElement: Copy, TGrid: Grid<TElement>> Grid<TElement>
 | 
				
			||||||
            for $name<'_, TElement, TGrid>
 | 
					            for $name<'_, TElement, TGrid>
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            #[must_use]
 | 
					            #[must_use]
 | 
				
			||||||
            #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					            fn get_optional(&self, x: usize, y: usize) -> Option<TElement> {
 | 
				
			||||||
            pub fn get_optional(&self, x: usize, y: usize) -> Option<TElement> {
 | 
					 | 
				
			||||||
                if self.is_in_bounds(x, y) {
 | 
					                if self.is_in_bounds(x, y) {
 | 
				
			||||||
                    Some(self.grid.get(self.xs.start + x, self.ys.start + y))
 | 
					                    Some(self.grid.get(self.xs.start + x, self.ys.start + y))
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
| 
						 | 
					@ -128,14 +125,12 @@ macro_rules! define_window {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #[must_use]
 | 
					            #[must_use]
 | 
				
			||||||
            #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					            fn width(&self) -> usize {
 | 
				
			||||||
            pub fn width(&self) -> usize {
 | 
					 | 
				
			||||||
                self.xs.len()
 | 
					                self.xs.len()
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            #[must_use]
 | 
					            #[must_use]
 | 
				
			||||||
            #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					            fn height(&self) -> usize {
 | 
				
			||||||
            pub fn height(&self) -> usize {
 | 
					 | 
				
			||||||
                self.ys.len()
 | 
					                self.ys.len()
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					@ -145,17 +140,10 @@ macro_rules! define_window {
 | 
				
			||||||
define_window!(Window, &'t TGrid);
 | 
					define_window!(Window, &'t TGrid);
 | 
				
			||||||
define_window!(WindowMut, &'t mut TGrid);
 | 
					define_window!(WindowMut, &'t mut TGrid);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[inherent::inherent]
 | 
					 | 
				
			||||||
impl<TElement: Copy, TGrid: GridMut<TElement>> GridMut<TElement>
 | 
					impl<TElement: Copy, TGrid: GridMut<TElement>> GridMut<TElement>
 | 
				
			||||||
    for WindowMut<'_, TElement, TGrid>
 | 
					    for WindowMut<'_, TElement, TGrid>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					    fn set_optional(&mut self, x: usize, y: usize, value: TElement) -> bool {
 | 
				
			||||||
    pub fn set_optional(
 | 
					 | 
				
			||||||
        &mut self,
 | 
					 | 
				
			||||||
        x: usize,
 | 
					 | 
				
			||||||
        y: usize,
 | 
					 | 
				
			||||||
        value: TElement,
 | 
					 | 
				
			||||||
    ) -> bool {
 | 
					 | 
				
			||||||
        if self.is_in_bounds(x, y) {
 | 
					        if self.is_in_bounds(x, y) {
 | 
				
			||||||
            self.grid.set(self.xs.start + x, self.ys.start + y, value);
 | 
					            self.grid.set(self.xs.start + x, self.ys.start + y, value);
 | 
				
			||||||
            true
 | 
					            true
 | 
				
			||||||
| 
						 | 
					@ -164,8 +152,7 @@ impl<TElement: Copy, TGrid: GridMut<TElement>> GridMut<TElement>
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[allow(unused, reason = "False positive because of #[inherent]")]
 | 
					    fn fill(&mut self, value: TElement) {
 | 
				
			||||||
    pub fn fill(&mut self, value: TElement) {
 | 
					 | 
				
			||||||
        for y in self.ys.clone() {
 | 
					        for y in self.ys.clone() {
 | 
				
			||||||
            for x in self.xs.clone() {
 | 
					            for x in self.xs.clone() {
 | 
				
			||||||
                self.grid.set(x, y, value);
 | 
					                self.grid.set(x, y, value);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue