Skip to content

Commit

Permalink
Adjust code and editor to 100 columns per Rust formatting guidelines
Browse files Browse the repository at this point in the history
  • Loading branch information
jmmv committed Jul 26, 2018
1 parent c15c30b commit dfdfb33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
"editor.quickSuggestions": false
},

"[rust]": {
"editor.rulers": [100],
"editor.wordWrapColumn": 100
},

"[troff]": {
"editor.quickSuggestions": false
}
Expand Down
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct SandboxFS {
impl SandboxFS {
/// Creates a new `SandboxFS` instance.
fn new() -> SandboxFS {
SandboxFS {}
SandboxFS {}
}
}

Expand All @@ -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)))
}
19 changes: 8 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();

Expand All @@ -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<String> = env::args().collect();
let program = program_name(&args, "sandboxfs");
Expand Down

0 comments on commit dfdfb33

Please sign in to comment.