experimenting with various ideas to avoid repeating code in config.rs

This commit is contained in:
2024-12-17 23:34:10 +01:00
parent d8f039d76b
commit 26733820f8
2 changed files with 16 additions and 1 deletions
+15
View File
@@ -10,6 +10,21 @@ use std::fs;
use std::io::{Error, Result};
use std::path::PathBuf;
// macro_rules! generate_field_names {
// ($(#[$attr:meta])* struct $name:ident { $($fname:ident : $ftype:ty),* }) => {
// $(#[$attr])* struct $name {
// $($fname : $ftype),*
// }
// impl $name {
// fn field_names() -> &'static [&'static str] {
// static NAMES: &'static [&'static str] = &[$(stringify!($fname)),*];
// NAMES
// }
// }
// }
// }
#[derive(Debug, Clone)]
pub struct Config {
conf_file: PathBuf,
+1 -1
View File
@@ -193,7 +193,7 @@ pub fn make_padding_string(len: usize) -> String {
/// convert color setting to ansi escape sequence
pub fn parse_color(color: String) -> Result<String> {
// check for numbered color
if let Ok(numbered) = color.parse::<u8>() {
if let Ok(numbered) = color.parse::<u8>() { // TODO: only accept numbers between 16 and 256
return Ok(generate_256color_sequence(
ColorContext::Foreground,
numbered,