types: better debug impl for BoundedAddress

This commit is contained in:
Alex Janka 2024-08-18 19:35:50 +10:00
parent 3d372d811a
commit bf3ed7ff24

View file

@ -5,9 +5,15 @@ use std::{
use crate::error::AddressError;
#[derive(Copy, Clone, Debug)]
#[derive(Copy, Clone)]
pub(crate) struct BoundedAddress<const MIN: u16, const MAX: u16>(u16);
impl<const MIN: u16, const MAX: u16> std::fmt::Debug for BoundedAddress<MIN, MAX> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:#04X}", self.0)
}
}
impl<const MIN: u16, const MAX: u16> Display for BoundedAddress<MIN, MAX> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Display::fmt(&self.0, f)