|
10 | 10 |
|
11 | 11 | extern crate toml;
|
12 | 12 |
|
| 13 | +use std::collections::HashMap; |
| 14 | +use std::path::PathBuf; |
| 15 | +use std::str; |
| 16 | + |
13 | 17 | use lists::{SeparatorTactic, ListTactic};
|
14 | 18 |
|
15 | 19 | macro_rules! configuration_option_enum{
|
@@ -80,6 +84,35 @@ configuration_option_enum! { TypeDensity:
|
80 | 84 | Wide,
|
81 | 85 | }
|
82 | 86 |
|
| 87 | +pub type LineRange = (usize, usize); |
| 88 | + |
| 89 | +// Newtype required to implement ConfigType and FromStr for the `create_config` macro. |
| 90 | +#[derive(Clone, Debug, RustcDecodable)] |
| 91 | +pub struct LineRanges(pub Vec<LineRange>); |
| 92 | + |
| 93 | +impl LineRanges { |
| 94 | + pub fn new() -> LineRanges { |
| 95 | + LineRanges(Vec::new()) |
| 96 | + } |
| 97 | +} |
| 98 | + |
| 99 | +// This impl is needed by the `create_config` macro. |
| 100 | +impl str::FromStr for LineRanges { |
| 101 | + type Err = (); |
| 102 | + fn from_str(_: &str) -> Result<LineRanges, ()> { |
| 103 | + unimplemented!(); |
| 104 | + } |
| 105 | +} |
| 106 | + |
| 107 | +// This impl is needed by the `create_config` macro. |
| 108 | +impl ConfigType for LineRanges { |
| 109 | + fn get_variant_names() -> String { |
| 110 | + String::from("<ranges>") |
| 111 | + } |
| 112 | +} |
| 113 | + |
| 114 | +pub type FileLinesMap = HashMap<PathBuf, LineRanges>; |
| 115 | + |
83 | 116 | impl Density {
|
84 | 117 | pub fn to_list_tactic(self) -> ListTactic {
|
85 | 118 | match self {
|
@@ -300,6 +333,7 @@ macro_rules! create_config {
|
300 | 333 | create_config! {
|
301 | 334 | Doc verbose: bool, false, "Use verbose output";
|
302 | 335 | Doc skip_children: bool, false, "Don't reformat out of line modules";
|
| 336 | + NoDoc line_ranges: LineRanges, LineRanges::new(), "Ranges of lines to format"; |
303 | 337 | Doc max_width: usize, 100, "Maximum width of each line";
|
304 | 338 | Doc ideal_width: usize, 80, "Ideal width of each line";
|
305 | 339 | Doc tab_spaces: usize, 4, "Number of spaces per tab";
|
|
0 commit comments