Format a setting value as a TOML string. This is mostly for use by the generated `Display` implementation.
(
&self,
detail: Detail,
byte: u8,
f: &mut fmt::Formatter,
)
| 346 | /// Format a setting value as a TOML string. This is mostly for use by the generated |
| 347 | /// `Display` implementation. |
| 348 | pub fn format_toml_value( |
| 349 | &self, |
| 350 | detail: Detail, |
| 351 | byte: u8, |
| 352 | f: &mut fmt::Formatter, |
| 353 | ) -> fmt::Result { |
| 354 | match detail { |
| 355 | Detail::Bool { bit } => write!(f, "{}", (byte & (1 << bit)) != 0), |
| 356 | Detail::Num => write!(f, "{byte}"), |
| 357 | Detail::Enum { last, enumerators } => { |
| 358 | if byte <= last { |
| 359 | let tags = self.enums(last, enumerators); |
| 360 | write!(f, "\"{}\"", tags[usize::from(byte)]) |
| 361 | } else { |
| 362 | write!(f, "{byte}") |
| 363 | } |
| 364 | } |
| 365 | // Presets aren't printed. They are reflected in the other settings. |
| 366 | Detail::Preset { .. } => Ok(()), |
| 367 | } |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | /// The template contains a hash table for by-name lookup. |