bit_string/bit_string/impls_for_fmt.rs
1use core::fmt;
2
3use super::*;
4
5impl fmt::Display for BitString {
6 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
7 for index in 0..self.len {
8 f.write_str(if self.get(index).unwrap() { "1" } else { "0" })?;
9 }
10
11 Ok(())
12 }
13}
14
15impl fmt::Debug for BitString {
16 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17 f.write_str("BitString(\"")?;
18 fmt::Display::fmt(self, f)?;
19 f.write_str("\")")
20 }
21}