diff --git a/src/config.rs b/src/config.rs index bd7e9377480..224a1951092 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,6 +10,10 @@ extern crate toml; +use std::collections::HashMap; +use std::path::PathBuf; +use std::str; + use lists::{SeparatorTactic, ListTactic}; macro_rules! configuration_option_enum{ @@ -80,6 +84,35 @@ configuration_option_enum! { TypeDensity: Wide, } +pub type LineRange = (usize, usize); + +// Newtype required to implement ConfigType and FromStr for the `create_config` macro. +#[derive(Clone, Debug, RustcDecodable)] +pub struct LineRanges(pub Vec); + +impl LineRanges { + pub fn new() -> LineRanges { + LineRanges(Vec::new()) + } +} + +// This impl is needed by the `create_config` macro. +impl str::FromStr for LineRanges { + type Err = (); + fn from_str(_: &str) -> Result { + unimplemented!(); + } +} + +// This impl is needed by the `create_config` macro. +impl ConfigType for LineRanges { + fn get_variant_names() -> String { + String::from("") + } +} + +pub type FileLinesMap = HashMap; + impl Density { pub fn to_list_tactic(self) -> ListTactic { match self { @@ -300,6 +333,7 @@ macro_rules! create_config { create_config! { Doc verbose: bool, false, "Use verbose output"; Doc skip_children: bool, false, "Don't reformat out of line modules"; + NoDoc line_ranges: LineRanges, LineRanges::new(), "Ranges of lines to format"; Doc max_width: usize, 100, "Maximum width of each line"; Doc ideal_width: usize, 80, "Ideal width of each line"; Doc tab_spaces: usize, 4, "Number of spaces per tab";