Skip to content

Commit

Permalink
Change the printing format for vec_debug
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed Nov 3, 2023
1 parent c013d3e commit 5fac825
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ fn main() {
println!("{:#010b}", Bitmask::Flag1); // 0b00000001
println!("{:#010b}", Bitmask::InvertedFlag1); // 0b11111110

println!("{:?}", BitmaskVecDebug::none()); // []
println!("{:?}", BitmaskVecDebug::Flag1); // [Flag1]
println!("{:?}", BitmaskVecDebug::full()); // [Flag1, Flag2]
println!("{:?}", BitmaskVecDebug::none()); // BitmaskVecDebug[]
println!("{:?}", BitmaskVecDebug::Flag1); // BitmaskVecDebug[Flag1]
println!("{:?}", BitmaskVecDebug::full()); // BitmaskVecDebug[Flag1, Flag2]
}
```

Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn parse(attr: TokenStream, mut item: ItemEnum) -> Result<TokenStream> {
matches.push(#all_flags_names);
})*

write!(f, "[{}]", matches.join(", "))
write!(f, "{}[{}]", stringify!(#ident), matches.join(", "))
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,13 +347,13 @@ mod tests {
Flag3,
}

assert_eq!(format!("{:?}", BitmaskVecDebug::none()), "[]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag1), "[Flag1]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag2), "[Flag2]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag12), "[Flag1, Flag2, Flag12]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag3), "[Flag3]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag2.or(BitmaskVecDebug::Flag3)), "[Flag2, Flag3]");
assert_eq!(format!("{:?}", BitmaskVecDebug::full()), "[Flag1, Flag2, Flag12, Flag3]");
assert_eq!(format!("{:?}", BitmaskVecDebug::none()), "BitmaskVecDebug[]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag1), "BitmaskVecDebug[Flag1]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag2), "BitmaskVecDebug[Flag2]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag12), "BitmaskVecDebug[Flag1, Flag2, Flag12]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag3), "BitmaskVecDebug[Flag3]");
assert_eq!(format!("{:?}", BitmaskVecDebug::Flag2.or(BitmaskVecDebug::Flag3)), "BitmaskVecDebug[Flag2, Flag3]");
assert_eq!(format!("{:?}", BitmaskVecDebug::full()), "BitmaskVecDebug[Flag1, Flag2, Flag12, Flag3]");

// default formatting
assert_eq!(format!("{:?}", Bitmask::none()), "Bitmask { bits: 0 }");
Expand Down

0 comments on commit 5fac825

Please sign in to comment.