yes_no/lib.rs
1use std::fmt;
2
3pub struct YesNo(pub bool);
4
5impl fmt::Display for YesNo {
6 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7 (if self.0 { "Yes" } else { "No" }).fmt(f)
8 }
9}
10
11#[test]
12fn sanity_check() {
13 assert_eq!(format!("{}", YesNo(true)), "Yes");
14 assert_eq!(format!("{}", YesNo(false)), "No");
15}