const_format/
for_examples.rs1use crate::{impl_fmt, try_, Error, Formatter, PWrapper};
8
9#[derive(Debug, Copy, Clone)]
11pub struct Point3 {
12 pub x: u32,
14 pub y: u32,
16 pub z: u32,
18}
19
20impl_fmt! {
21 impl Point3;
22
23 pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
25 let mut f = f.debug_struct("Point3");
26 try_!(PWrapper(self.x).const_debug_fmt(f.field("x")));
27 try_!(PWrapper(self.y).const_debug_fmt(f.field("y")));
28 try_!(PWrapper(self.z).const_debug_fmt(f.field("z")));
29 f.finish()
30 }
31
32 pub const fn const_eq(&self, other: &Self) -> bool {
34 self.x == other.x &&
35 self.y == other.y &&
36 self.z == other.z
37 }
38}
39
40#[derive(Debug, Copy, Clone)]
42pub struct Unit;
43
44impl_fmt! {
45 impl Unit;
46
47 pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
49 f.debug_struct("Unit").finish()
50 }
51
52 pub const fn const_eq(&self, _other: &Self) -> bool {
54 true
55 }
56}