experimenting with various ideas to avoid repeating code in config.rs
This commit is contained in:
@@ -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
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user