Cleanup value by using DebugCustom
This commit is contained in:
parent
e4f6ae2854
commit
8c939fb054
2 changed files with 7 additions and 21 deletions
|
@ -3,20 +3,16 @@ use derive_more::*;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use std::{fmt, str::FromStr};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Display)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Deserialize, Serialize, Display, DebugCustom)]
|
||||
pub enum NumWithUnit {
|
||||
#[display(fmt = "{}%", .0)]
|
||||
#[debug(fmt = "{}%", .0)]
|
||||
Percent(i32),
|
||||
#[display(fmt = "{}px", .0)]
|
||||
#[debug(fmt = "{}px", .0)]
|
||||
Pixels(i32),
|
||||
}
|
||||
|
||||
impl fmt::Debug for NumWithUnit {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for NumWithUnit {
|
||||
type Err = anyhow::Error;
|
||||
|
||||
|
|
|
@ -12,7 +12,8 @@ pub use primitive::*;
|
|||
|
||||
/// The name of a variable
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Hash, PartialEq, Eq, Serialize, Deserialize, RefCast, AsRef, From, FromStr, Display)]
|
||||
#[derive(Clone, Hash, PartialEq, Eq, Serialize, Deserialize, RefCast, AsRef, From, FromStr, Display, DebugCustom)]
|
||||
#[debug(fmt = "VarName({})", .0)]
|
||||
pub struct VarName(pub String);
|
||||
|
||||
impl std::borrow::Borrow<str> for VarName {
|
||||
|
@ -27,15 +28,10 @@ impl From<&str> for VarName {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for VarName {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "VarName(\"{}\")", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// The name of an attribute
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Hash, PartialEq, Eq, Serialize, Deserialize, RefCast, AsRef, From, FromStr, Display)]
|
||||
#[derive(Clone, Hash, PartialEq, Eq, Serialize, Deserialize, RefCast, AsRef, From, FromStr, Display, DebugCustom)]
|
||||
#[debug(fmt="AttrName({})", .0)]
|
||||
pub struct AttrName(pub String);
|
||||
|
||||
impl std::borrow::Borrow<str> for AttrName {
|
||||
|
@ -49,9 +45,3 @@ impl From<&str> for AttrName {
|
|||
AttrName(s.to_owned())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for AttrName {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "AttrName(\"{}\")", self.0)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue