From eb42e0aba1527643806d875740509aca4aa6edcc Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Tue, 12 Nov 2024 19:36:12 +0100 Subject: [PATCH] add derives, u8::from(&Brightness) --- crates/servicepoint/src/bitmap.rs | 2 +- crates/servicepoint/src/brightness.rs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/servicepoint/src/bitmap.rs b/crates/servicepoint/src/bitmap.rs index d7d7a77..697a0d5 100644 --- a/crates/servicepoint/src/bitmap.rs +++ b/crates/servicepoint/src/bitmap.rs @@ -5,7 +5,7 @@ use bitvec::slice::IterMut; use crate::{BitVec, DataRef, Grid, PIXEL_HEIGHT, PIXEL_WIDTH}; /// A grid of pixels stored in packed bytes. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Bitmap { width: usize, height: usize, diff --git a/crates/servicepoint/src/brightness.rs b/crates/servicepoint/src/brightness.rs index 009b8fe..29c5576 100644 --- a/crates/servicepoint/src/brightness.rs +++ b/crates/servicepoint/src/brightness.rs @@ -19,7 +19,7 @@ use rand::{ /// # let connection = Connection::open("127.0.0.1:2342").unwrap(); /// let result = connection.send(Command::Brightness(b)); /// ``` -#[derive(Debug, Copy, Clone, PartialEq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, Ord, PartialOrd)] pub struct Brightness(u8); /// A grid containing brightness values. @@ -50,6 +50,12 @@ impl From for u8 { } } +impl From<&Brightness> for u8 { + fn from(brightness: &Brightness) -> Self { + brightness.0 + } +} + impl TryFrom for Brightness { type Error = u8;