more clippy fixes and/or whitelists

This commit is contained in:
Vinzenz Schroeter 2025-03-25 20:01:04 +01:00
parent 9f239ec71d
commit 61f83a7042
4 changed files with 20 additions and 13 deletions

View file

@ -2,8 +2,10 @@
use clap::Parser;
use rand::{distributions, Rng};
use servicepoint::*;
use std::net::UdpSocket;
use servicepoint::{
Bitmap, BitmapCommand, CompressionCode, Connection, Grid, Origin,
UdpConnection, FRAME_PACING,
};
use std::thread;
#[derive(Parser, Debug)]
@ -40,10 +42,8 @@ fn iteration(field: Bitmap) -> Bitmap {
let old_state = field.get(x, y);
let neighbors = count_neighbors(&field, x as i32, y as i32);
let new_state = matches!(
(old_state, neighbors),
(true, 2) | (true, 3) | (false, 3)
);
let new_state =
matches!((old_state, neighbors), (true, 2 | 3) | (false, 3));
next.set(x, y, new_state);
}
}

View file

@ -3,7 +3,11 @@
use clap::Parser;
use rand::Rng;
use servicepoint::*;
use servicepoint::{
Bitmap, BitmapCommand, Brightness, BrightnessCommand, BrightnessGrid,
BrightnessGridCommand, CompressionCode, Connection, Grid, Origin,
UdpConnection, TILE_HEIGHT, TILE_WIDTH,
};
use std::time::Duration;
#[derive(Parser, Debug)]
@ -38,7 +42,7 @@ fn main() {
// set all pixels to the same random brightness
let mut rng = rand::thread_rng();
let command: BrightnessCommand = rng.gen::<Brightness>().into();
let command: BrightnessCommand = rng.r#gen::<Brightness>().into();
connection.send(command).unwrap();
// continuously update random windows to new random brightness
@ -55,7 +59,7 @@ fn main() {
for y in 0..h {
for x in 0..w {
luma.set(x, y, rng.gen());
luma.set(x, y, rng.r#gen());
}
}

View file

@ -1,6 +1,9 @@
//! Example for how to use the WebSocket connection
use servicepoint::*;
use servicepoint::{
Bitmap, BitmapCommand, ClearCommand, CompressionCode, Connection, Grid,
Origin, WebsocketConnection,
};
fn main() {
let uri = "ws://localhost:8080".parse().unwrap();

View file

@ -6,9 +6,9 @@ use std::{error::Error, fmt::Debug};
/// Note that you will need to forward the WebSocket messages via UDP to the display.
/// You can use [servicepoint-websocket-relay] for this.
///
/// To create a new WebSocket automatically, use [Connection::open_websocket].
/// To create a new WebSocket automatically, use [`Connection::open_websocket`].
///
/// Requires the feature "protocol_websocket" which is disabled by default.
/// Requires the feature "`protocol_websocket`" which is disabled by default.
///
/// [servicepoint-websocket-relay]: https://github.com/kaesaecracker/servicepoint-websocket-relay
#[derive(Debug)]
@ -48,7 +48,7 @@ impl Connection for WebsocketConnection {
impl WebsocketConnection {
/// Open a new WebSocket and connect to the provided host.
///
/// Requires the feature "protocol_websocket" which is disabled by default.
/// Requires the feature "`protocol_websocket`" which is disabled by default.
///
/// # Examples
///