Skip to content
This repository has been archived by the owner on Feb 12, 2018. It is now read-only.

Commit

Permalink
Cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
trishume committed Jun 13, 2016
1 parent 6e6b889 commit 78bf6e2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
3 changes: 2 additions & 1 deletion src/dumps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ impl PackageSet {
/// use the fact that SyntaxDefinitions are serializable with
/// the bincode crate to cache dumps of additional syntaxes yourself.
pub fn load_defaults_nonewlines() -> PackageSet {
let mut ps: PackageSet = from_binary(include_bytes!("../assets/default_nonewlines.packdump"));
let mut ps: PackageSet = from_binary(include_bytes!("../assets/default_nonewlines.\
packdump"));
ps.link_syntaxes();
ps
}
Expand Down
4 changes: 2 additions & 2 deletions src/package_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use syntax_definition::*;
use scope::*;
use yaml_load::*;

use std::path::{Path};
use std::io::{Error as IoError};
use std::path::Path;
use std::io::Error as IoError;
use walkdir::WalkDir;
use std::io::{self, Read};
use std::fs::File;
Expand Down
2 changes: 1 addition & 1 deletion src/theme/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ mod tests {
}
#[test]
fn matching_works() {
use scope::{ScopeStack,MatchPower};
use scope::{ScopeStack, MatchPower};
use theme::selector::*;
use std::str::FromStr;
assert_eq!(ScopeSelectors::from_str("a.b, a e, e.f")
Expand Down
29 changes: 15 additions & 14 deletions src/theme_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use std::io::{Error as IoError, BufReader};
use walkdir::WalkDir;
use std::io::{self};
use std::io;
use std::fs::File;
use walkdir;

Expand Down Expand Up @@ -43,28 +43,28 @@ impl From<ParseThemeError> for ThemeSetError {
impl ThemeSet {
/// Returns all the themes found in a folder, good for enumerating before loading one with get_theme
pub fn discover_theme_paths<P: AsRef<Path>>(folder: P) -> Result<Vec<PathBuf>, ThemeSetError> {
let mut themes = Vec::new();
for entry in WalkDir::new(folder) {
let entry = try!(entry.map_err(|e| ThemeSetError::WalkDir(e)));
if entry.path().extension().map(|e| e == "tmTheme").unwrap_or(false) {
themes.push(entry.path().to_owned());
}
}
Ok(themes)
let mut themes = Vec::new();
for entry in WalkDir::new(folder) {
let entry = try!(entry.map_err(|e| ThemeSetError::WalkDir(e)));
if entry.path().extension().map(|e| e == "tmTheme").unwrap_or(false) {
themes.push(entry.path().to_owned());
}
}
Ok(themes)
}

fn read_file(path: &Path) -> Result<BufReader<File>, ThemeSetError> {
let reader = try!(File::open(path));
Ok(BufReader::new(reader))
let reader = try!(File::open(path));
Ok(BufReader::new(reader))
}

fn read_plist(path: &Path) -> Result<Settings, ThemeSetError> {
Ok(try!(read_plist(try!(Self::read_file(path)))))
Ok(try!(read_plist(try!(Self::read_file(path)))))
}

/// Loads a theme given a path to a .tmTheme file
pub fn get_theme<P: AsRef<Path>>(path: P) -> Result<Theme, ThemeSetError> {
Ok(try!(Theme::parse_settings(try!(Self::read_plist(path.as_ref())))))
Ok(try!(Theme::parse_settings(try!(Self::read_plist(path.as_ref())))))
}

/// Loads all the themes in a folder
Expand All @@ -73,7 +73,8 @@ impl ThemeSet {
let mut map = BTreeMap::new();
for p in paths.iter() {
let theme = try!(Self::get_theme(p));
let basename = try!(p.file_stem().and_then(|x| x.to_str()).ok_or(ThemeSetError::BadPath));
let basename =
try!(p.file_stem().and_then(|x| x.to_str()).ok_or(ThemeSetError::BadPath));
map.insert(basename.to_owned(), theme);
}
Ok(ThemeSet { themes: map })
Expand Down

0 comments on commit 78bf6e2

Please sign in to comment.