mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 20:34:52 -06:00
Remove some multiple newlines
This commit is contained in:
@@ -11,13 +11,11 @@ use std::collections::BTreeMap;
|
|||||||
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
|
||||||
static PATTERNS: &'static [(&'static str, &'static str)] = &[
|
static PATTERNS: &'static [(&'static str, &'static str)] = &[
|
||||||
(r"ch(\d\d)-\d\d-.*\.md", "chapter$1.md"),
|
(r"ch(\d\d)-\d\d-.*\.md", "chapter$1.md"),
|
||||||
(r"appendix-(\d\d).*\.md", "appendix.md"),
|
(r"appendix-(\d\d).*\.md", "appendix.md"),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref MATCHERS: Vec<(Regex, &'static str)> = {
|
static ref MATCHERS: Vec<(Regex, &'static str)> = {
|
||||||
PATTERNS.iter()
|
PATTERNS.iter()
|
||||||
@@ -26,7 +24,6 @@ lazy_static! {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
|
||||||
@@ -46,8 +43,6 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn match_files(source_dir: &Path, target_dir: &Path) -> Vec<(PathBuf, PathBuf)> {
|
fn match_files(source_dir: &Path, target_dir: &Path) -> Vec<(PathBuf, PathBuf)> {
|
||||||
read_dir(source_dir)
|
read_dir(source_dir)
|
||||||
.expect("Unable to read source directory")
|
.expect("Unable to read source directory")
|
||||||
@@ -69,7 +64,6 @@ fn match_files(source_dir: &Path, target_dir: &Path) -> Vec<(PathBuf, PathBuf)>
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn group_by_target(matched_files: Vec<(PathBuf, PathBuf)>) -> BTreeMap<PathBuf, Vec<PathBuf>> {
|
fn group_by_target(matched_files: Vec<(PathBuf, PathBuf)>) -> BTreeMap<PathBuf, Vec<PathBuf>> {
|
||||||
let mut grouped: BTreeMap<PathBuf, Vec<PathBuf>> = BTreeMap::new();
|
let mut grouped: BTreeMap<PathBuf, Vec<PathBuf>> = BTreeMap::new();
|
||||||
for (source, target) in matched_files {
|
for (source, target) in matched_files {
|
||||||
@@ -83,7 +77,6 @@ fn group_by_target(matched_files: Vec<(PathBuf, PathBuf)>) -> BTreeMap<PathBuf,
|
|||||||
grouped
|
grouped
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn concat_files(source_paths: Vec<PathBuf>, target_path: PathBuf) -> io::Result<()> {
|
fn concat_files(source_paths: Vec<PathBuf>, target_path: PathBuf) -> io::Result<()> {
|
||||||
println!("Concatenating into {}:", target_path.to_string_lossy());
|
println!("Concatenating into {}:", target_path.to_string_lossy());
|
||||||
let mut target = try!(File::create(target_path));
|
let mut target = try!(File::create(target_path));
|
||||||
@@ -104,7 +97,6 @@ fn concat_files(source_paths: Vec<PathBuf>, target_path: PathBuf) -> io::Result<
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn ensure_dir_exists(dir_string: &str) -> io::Result<&Path> {
|
fn ensure_dir_exists(dir_string: &str) -> io::Result<&Path> {
|
||||||
let path = Path::new(dir_string);
|
let path = Path::new(dir_string);
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
|
|||||||
Reference in New Issue
Block a user