From 2f5a682754f2808a6e2443410826999c1891a24e Mon Sep 17 00:00:00 2001 From: Julio Merino Date: Thu, 26 Jul 2018 11:12:43 -0400 Subject: [PATCH] Adjust code and editor to 100 columns per Rust formatting guidelines --- .vscode/settings.json.in | 5 +++++ src/lib.rs | 3 +-- src/main.rs | 19 ++++++++----------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.vscode/settings.json.in b/.vscode/settings.json.in index 7c96be0..90a76aa 100644 --- a/.vscode/settings.json.in +++ b/.vscode/settings.json.in @@ -41,6 +41,11 @@ "editor.quickSuggestions": false }, + "[rust]": { + "editor.rulers": [100], + "editor.wordWrapColumn": 100 + }, + "[troff]": { "editor.quickSuggestions": false } diff --git a/src/lib.rs b/src/lib.rs index 7377ebc..e6eec4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,6 +42,5 @@ pub fn mount(mount_point: &Path) -> io::Result<()> { let fs = SandboxFS::new(); info!("Mounting file system onto {:?}", mount_point); fuse::mount(fs, &mount_point, &options) - .map_err(|e| io::Error::new( - e.kind(), format!("mount on {:?} failed: {}", mount_point, e))) + .map_err(|e| io::Error::new(e.kind(), format!("mount on {:?} failed: {}", mount_point, e))) } diff --git a/src/main.rs b/src/main.rs index e4b7653..c1230cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,8 +31,8 @@ struct UsageError { message: String, } -/// Obtains the program name from the execution's first argument, or returns a -/// default if the program name cannot be determined for whatever reason. +/// Obtains the program name from the execution's first argument, or returns a default if the +/// program name cannot be determined for whatever reason. fn program_name(args: &[String], default: &'static str) -> String { let default = String::from(default); match args.get(0) { @@ -53,9 +53,9 @@ fn usage(program: &str, opts: &Options) { print!("{}", opts.usage(&brief)); } -/// Program's entry point. This is a "safe" version of `main` in the sense that -/// this doesn't directly handle errors: all errors are returned to the caller -/// for consistent reporter to the user depending on their type. +/// Program's entry point. This is a "safe" version of `main` in the sense that this doesn't +/// directly handle errors: all errors are returned to the caller for consistent reporter to the +/// user depending on their type. fn safe_main(program: &str, args: &[String]) -> Result<(), Error> { env_logger::init(); @@ -71,18 +71,15 @@ fn safe_main(program: &str, args: &[String]) -> Result<(), Error> { let mount_point = if matches.free.len() == 1 { &matches.free[0] } else { - return Err(Error::from(UsageError { - message: "invalid number of arguments".to_string(), - })); + return Err(Error::from(UsageError { message: "invalid number of arguments".to_string() })); }; sandboxfs::mount(Path::new(mount_point))?; Ok(()) } -/// Program's entry point. This delegates to `safe_main` for all program logic -/// and is just in charge of consistently formatting and reporting all possible -/// errors to the caller. +/// Program's entry point. This delegates to `safe_main` for all program logic and is just in +/// charge of consistently formatting and reporting all possible errors to the caller. fn main() { let args: Vec = env::args().collect(); let program = program_name(&args, "sandboxfs");