From 44ccc4f04b94db338cbaecbae3bc6de661afaf53 Mon Sep 17 00:00:00 2001
From: Michael Aaron Murphy <mmstickman@gmail.com>
Date: Thu, 26 Oct 2017 10:57:59 -0400
Subject: [PATCH] Run rustfmt again

---
 src/builtins/mod.rs                           | 14 +++----
 src/parser/quotes.rs                          | 26 ++++++------
 src/parser/shell_expand/mod.rs                |  6 ++-
 .../shell_expand/words/methods/arrays.rs      |  2 +-
 src/parser/shell_expand/words/methods/mod.rs  |  6 +--
 .../shell_expand/words/methods/strings.rs     | 36 ++++++++--------
 src/parser/shell_expand/words/select.rs       |  6 +--
 src/parser/statement/splitter.rs              |  4 +-
 src/shell/binary.rs                           | 42 ++++++++++++-------
 src/sys/redox.rs                              |  8 ++++
 src/sys/unix.rs                               | 19 +--------
 11 files changed, 89 insertions(+), 80 deletions(-)

diff --git a/src/builtins/mod.rs b/src/builtins/mod.rs
index 75f40259..9f97dd79 100644
--- a/src/builtins/mod.rs
+++ b/src/builtins/mod.rs
@@ -22,7 +22,7 @@ use self::variables::{alias, drop_alias, drop_array, drop_variable};
 
 use fnv::FnvHashMap;
 use std::error::Error;
-use std::io::{self, Write, BufWriter};
+use std::io::{self, BufWriter, Write};
 
 use parser::QuoteTerminator;
 use shell::{self, FlowLogic, Shell, ShellHistory};
@@ -200,17 +200,13 @@ fn list_vars(_: &[&str], shell: &mut Shell) -> i32 {
 
     // Write all the string variables to the buffer.
     let _ = buffer.write(b"# String Variables\n");
-    shell.variables.variables.iter().for_each(
-        |(key, val)| {
-            let _ = buffer.write([key, " = ", val.as_str(), "\n"].concat().as_bytes());
-        }
-    );
+    shell.variables.variables.iter().for_each(|(key, val)| {
+        let _ = buffer.write([key, " = ", val.as_str(), "\n"].concat().as_bytes());
+    });
 
     // Then immediately follow that with a list of array variables.
     let _ = buffer.write(b"\n# Array Variables\n");
-    shell.variables.arrays.iter().for_each(
-        |(key, val)| print_array(&mut buffer, &key, &val)
-    );
+    shell.variables.arrays.iter().for_each(|(key, val)| print_array(&mut buffer, &key, &val));
 
     SUCCESS
 }
diff --git a/src/parser/quotes.rs b/src/parser/quotes.rs
index 87084cef..6fdcb9d4 100644
--- a/src/parser/quotes.rs
+++ b/src/parser/quotes.rs
@@ -55,7 +55,9 @@ impl QuoteTerminator {
                     while let Some(character) = bytes.next() {
                         self.read += 1;
                         match character {
-                            b'\\' => { let _ = bytes.next(); },
+                            b'\\' => {
+                                let _ = bytes.next();
+                            }
                             b'\'' if !self.flags.intersects(DQUOTE) => self.flags ^= SQUOTE,
                             b'"' if !self.flags.intersects(SQUOTE) => self.flags ^= DQUOTE,
                             b'<' if !self.flags.contains(SQUOTE | DQUOTE) => {
@@ -78,20 +80,20 @@ impl QuoteTerminator {
                             }
                             b']' if !self.flags.intersects(DQUOTE | SQUOTE) => {
                                 self.array -= 1;
-                                if self.array == 0 { self.flags -= ARRAY }
+                                if self.array == 0 {
+                                    self.flags -= ARRAY
+                                }
                             }
-                            b'#' if !self.flags.intersects(DQUOTE | SQUOTE) => {
-                                if self.read > 1 {
-                                    let character = self.buffer.as_bytes().get(self.read - 2).unwrap();
-                                    if [b' ', b'\n'].contains(character) {
-                                        instance |= COMM;
-                                        break
-                                    }
-                                } else {
+                            b'#' if !self.flags.intersects(DQUOTE | SQUOTE) => if self.read > 1 {
+                                let character = self.buffer.as_bytes().get(self.read - 2).unwrap();
+                                if [b' ', b'\n'].contains(character) {
                                     instance |= COMM;
-                                    break
+                                    break;
                                 }
-                            }
+                            } else {
+                                instance |= COMM;
+                                break;
+                            },
                             _ => (),
                         }
                     }
diff --git a/src/parser/shell_expand/mod.rs b/src/parser/shell_expand/mod.rs
index 6f9fa498..ab8892f8 100644
--- a/src/parser/shell_expand/mod.rs
+++ b/src/parser/shell_expand/mod.rs
@@ -208,7 +208,8 @@ pub(crate) fn expand_tokens<E: Expander>(
             for word in token_buffer {
                 match *word {
                     WordToken::Array(ref elements, ref index) => {
-                        output.push_str(&array_expand(elements, expand_func, index.clone()).join(" "));
+                        output
+                            .push_str(&array_expand(elements, expand_func, index.clone()).join(" "));
                     }
                     WordToken::ArrayVariable(array, _, ref index) => {
                         if let Some(array) = expand_func.array(array, index.clone()) {
@@ -231,7 +232,8 @@ pub(crate) fn expand_tokens<E: Expander>(
                         Select::Index(Index::Backward(id)) => {
                             let mut temp = String::new();
                             expand_process(&mut temp, command, Select::All, expand_func);
-                            output.push_str(temp.split_whitespace().rev().nth(id).unwrap_or_default());
+                            output
+                                .push_str(temp.split_whitespace().rev().nth(id).unwrap_or_default());
                         }
                         Select::Range(range) => {
                             let mut temp = String::new();
diff --git a/src/parser/shell_expand/words/methods/arrays.rs b/src/parser/shell_expand/words/methods/arrays.rs
index 73baf2fa..002dabbc 100644
--- a/src/parser/shell_expand/words/methods/arrays.rs
+++ b/src/parser/shell_expand/words/methods/arrays.rs
@@ -1,7 +1,7 @@
 use super::Pattern;
 use super::pattern::unescape;
 use super::super::{Index, Select, SelectWithSize};
-use super::super::super::{expand_string, Expander, is_expression};
+use super::super::super::{expand_string, is_expression, Expander};
 use smallstring::SmallString;
 use std::char;
 use std::io::{self, Write};
diff --git a/src/parser/shell_expand/words/methods/mod.rs b/src/parser/shell_expand/words/methods/mod.rs
index efede944..d6c47330 100644
--- a/src/parser/shell_expand/words/methods/mod.rs
+++ b/src/parser/shell_expand/words/methods/mod.rs
@@ -6,9 +6,9 @@ pub(crate) use self::arrays::ArrayMethod;
 pub(crate) use self::pattern::Pattern;
 pub(crate) use self::strings::StringMethod;
 
-use super::{Expander, expand_string};
-use super::super::super::ArgumentSplitter;
 use self::pattern::unescape;
+use super::{expand_string, Expander};
+use super::super::super::ArgumentSplitter;
 
 #[derive(Debug, PartialEq, Clone)]
 pub(crate) struct Key {
@@ -40,4 +40,4 @@ impl<'a, 'b, E: 'b + Expander> MethodArgs<'a, 'b, E> {
             .flat_map(move |x| expand_string(x, self.expand, false).into_iter())
             .map(unescape)
     }
-}
\ No newline at end of file
+}
diff --git a/src/parser/shell_expand/words/methods/strings.rs b/src/parser/shell_expand/words/methods/strings.rs
index 4b7ba443..50a873d2 100644
--- a/src/parser/shell_expand/words/methods/strings.rs
+++ b/src/parser/shell_expand/words/methods/strings.rs
@@ -1,9 +1,9 @@
 use super::MethodArgs;
 use super::super::Select;
-use super::super::super::{expand_string, Expander, is_expression, slice};
+use super::super::super::{expand_string, is_expression, slice, Expander};
 use parser::assignments::is_array;
-use shell::plugins::methods::{self, MethodArguments, StringMethodPlugins};
 use regex::Regex;
+use shell::plugins::methods::{self, MethodArguments, StringMethodPlugins};
 use std::path::Path;
 use sys;
 use unicode_segmentation::UnicodeSegmentation;
@@ -103,36 +103,38 @@ impl<'a> StringMethod<'a> {
                     (Some(replace), Some(with)) => {
                         let res = &get_var!().replace(&replace, &with);
                         output.push_str(res);
-                    },
-                    _ => eprintln!("ion: replace: two arguments are required")
+                    }
+                    _ => eprintln!("ion: replace: two arguments are required"),
                 }
             }
             "replacen" => {
                 let mut args = pattern.array();
                 match (args.next(), args.next(), args.next()) {
-                    (Some(replace), Some(with), Some(nth)) => if let Ok(nth) = nth.parse::<usize>() {
+                    (Some(replace), Some(with), Some(nth)) => if let Ok(nth) = nth.parse::<usize>()
+                    {
                         let res = &get_var!().replacen(&replace, &with, nth);
                         output.push_str(res);
                     } else {
                         eprintln!("ion: replacen: third argument isn't a valid integer");
                     },
-                    _ => eprintln!("ion: replacen: three arguments required")
+                    _ => eprintln!("ion: replacen: three arguments required"),
                 }
             }
             "regex_replace" => {
                 let mut args = pattern.array();
-                match (args.next(),args.next()) {
-                    (Some(replace),Some(with)) => {
-                        match Regex::new(&replace){
-                            Ok(re) => {
-                                let inp = &get_var!();
-                                let res = re.replace_all(&inp,&with[..]);
-                                output.push_str(&res);
-                            }
-                            Err(_) => eprintln!("ion: regex_replace: error in regular expression {}",&replace)
+                match (args.next(), args.next()) {
+                    (Some(replace), Some(with)) => match Regex::new(&replace) {
+                        Ok(re) => {
+                            let inp = &get_var!();
+                            let res = re.replace_all(&inp, &with[..]);
+                            output.push_str(&res);
                         }
-                    }
-                    _ => eprintln!("ion: regex_replace: two arguments required")
+                        Err(_) => eprintln!(
+                            "ion: regex_replace: error in regular expression {}",
+                            &replace
+                        ),
+                    },
+                    _ => eprintln!("ion: regex_replace: two arguments required"),
                 }
             }
             "join" => {
diff --git a/src/parser/shell_expand/words/select.rs b/src/parser/shell_expand/words/select.rs
index 6ca210dc..84396091 100644
--- a/src/parser/shell_expand/words/select.rs
+++ b/src/parser/shell_expand/words/select.rs
@@ -1,7 +1,7 @@
-use super::super::ranges::parse_index_range;
 use super::{Index, Range};
-use std::iter::{empty, FromIterator};
 use super::methods::Key;
+use super::super::ranges::parse_index_range;
+use std::iter::{empty, FromIterator};
 use std::str::FromStr;
 
 
@@ -66,4 +66,4 @@ impl FromStr for Select {
 
         Ok(Select::Key(Key { key: data.into() }))
     }
-}
\ No newline at end of file
+}
diff --git a/src/parser/statement/splitter.rs b/src/parser/statement/splitter.rs
index d263c896..6cf29e7a 100644
--- a/src/parser/statement/splitter.rs
+++ b/src/parser/statement/splitter.rs
@@ -279,7 +279,9 @@ impl<'a> Iterator for StatementSplitter<'a> {
                 }
                 None => {
                     let output = self.data[start..].trim();
-                    if output.is_empty() { return Some(Ok(output)); }
+                    if output.is_empty() {
+                        return Some(Ok(output));
+                    }
                     match output.as_bytes()[0] {
                         b'>' | b'<' | b'^' => {
                             Some(Err(StatementError::ExpectedCommandButFound("redirection")))
diff --git a/src/shell/binary.rs b/src/shell/binary.rs
index 2467e81b..a3ca88ab 100644
--- a/src/shell/binary.rs
+++ b/src/shell/binary.rs
@@ -116,10 +116,7 @@ impl<'a> Binary for Shell<'a> {
 
                 let line = self.context.as_mut().unwrap().read_line(
                     prompt,
-                    &mut move |Event {
-                                   editor,
-                                   kind,
-                               }| {
+                    &mut move |Event { editor, kind }| {
                         if let EventKind::BeforeComplete = kind {
                             let (words, pos) = editor.get_words_and_cursor_position();
 
@@ -131,7 +128,8 @@ impl<'a> Binary for Shell<'a> {
                                 CursorPosition::OnWordRightEdge(index) => {
                                     match (words.into_iter().nth(index), env::current_dir()) {
                                         (Some((start, end)), Ok(file)) => {
-                                            let filename = editor.current_buffer().range(start, end);
+                                            let filename =
+                                                editor.current_buffer().range(start, end);
                                             complete_as_file(file, filename, index)
                                         }
                                         _ => false,
@@ -142,12 +140,17 @@ impl<'a> Binary for Shell<'a> {
                             if filename {
                                 if let Ok(current_dir) = env::current_dir() {
                                     if let Some(url) = current_dir.to_str() {
-                                        let completer = IonFileCompleter::new(Some(url), dirs_ptr, vars_ptr);
-                                        mem::replace(&mut editor.context().completer, Some(Box::new(completer)));
+                                        let completer =
+                                            IonFileCompleter::new(Some(url), dirs_ptr, vars_ptr);
+                                        mem::replace(
+                                            &mut editor.context().completer,
+                                            Some(Box::new(completer)),
+                                        );
                                     }
                                 }
                             } else {
-                                // Creates a list of definitions from the shell environment that will be used
+                                // Creates a list of definitions from the shell environment that
+                                // will be used
                                 // in the creation of a custom completer.
                                 let words = builtins.iter()
                                 // Add built-in commands to the completer's definitions.
@@ -167,7 +170,8 @@ impl<'a> Binary for Shell<'a> {
                                 // Initialize a new completer from the definitions collected.
                                 let custom_completer = BasicCompleter::new(words);
 
-                                // Creates completers containing definitions from all directories listed
+                                // Creates completers containing definitions from all directories
+                                // listed
                                 // in the environment's **$PATH** variable.
                                 let mut file_completers = if let Ok(val) = env::var("PATH") {
                                     val.split(sys::PATH_SEPARATOR)
@@ -177,18 +181,26 @@ impl<'a> Binary for Shell<'a> {
                                     vec![IonFileCompleter::new(Some("/bin/"), dirs_ptr, vars_ptr)]
                                 };
 
-                                // Also add files/directories in the current directory to the completion list.
+                                // Also add files/directories in the current directory to the
+                                // completion list.
                                 if let Ok(current_dir) = env::current_dir() {
                                     if let Some(url) = current_dir.to_str() {
-                                        file_completers.push(IonFileCompleter::new(Some(url), dirs_ptr, vars_ptr));
+                                        file_completers.push(
+                                            IonFileCompleter::new(Some(url), dirs_ptr, vars_ptr),
+                                        );
                                     }
                                 }
 
                                 // Merge the collected definitions with the file path definitions.
-                                let completer = MultiCompleter::new(file_completers, custom_completer);
-
-                                // Replace the shell's current completer with the newly-created completer.
-                                mem::replace(&mut editor.context().completer, Some(Box::new(completer)));
+                                let completer =
+                                    MultiCompleter::new(file_completers, custom_completer);
+
+                                // Replace the shell's current completer with the newly-created
+                                // completer.
+                                mem::replace(
+                                    &mut editor.context().completer,
+                                    Some(Box::new(completer)),
+                                );
                             }
                         }
                     },
diff --git a/src/sys/redox.rs b/src/sys/redox.rs
index 4c4ec291..a314db42 100644
--- a/src/sys/redox.rs
+++ b/src/sys/redox.rs
@@ -100,6 +100,10 @@ fn cvt(result: Result<usize, syscall::Error>) -> io::Result<usize> {
 // TODO
 pub mod signals {
     pub(crate) fn block()
+    // fn block()
+    // fn block()
+    // fn block()
+    // fn block()
     // fn block() // fn block() // fn block() // fn block() // fn block() //
     // fn block()
     {
@@ -110,6 +114,10 @@ pub mod signals {
     /// by the shell.
     pub(crate) fn unblock()
     // fn unblock()
+    // fn unblock()
+    // fn unblock()
+    // fn unblock()
+    // fn unblock()
     // fn unblock() // fn unblock() // fn unblock() // fn unblock() // fn
     // unblock()
     {
diff --git a/src/sys/unix.rs b/src/sys/unix.rs
index 3ad9105e..d287f4bc 100644
--- a/src/sys/unix.rs
+++ b/src/sys/unix.rs
@@ -106,14 +106,7 @@ fn cvt<T: IsMinusOne>(t: T) -> io::Result<T> {
 pub mod signals {
     /// Blocks the SIGTSTP/SIGTTOU/SIGTTIN/SIGCHLD signals so that the shell never receives
     /// them.
-    pub(crate) fn block()
-    // fn block()
-    // fn block()
-    // fn block()
-    // fn block()
-    // fn block() // fn block() // fn block() // fn block() // fn block() //
-    // fn block()
-    {
+    pub(crate) fn block() {
         unsafe {
             use libc::*;
             use std::mem;
@@ -131,15 +124,7 @@ pub mod signals {
     /// Unblocks the SIGTSTP/SIGTTOU/SIGTTIN/SIGCHLD signals so children processes can be
     /// controlled
     /// by the shell.
-    pub(crate) fn unblock()
-    // fn unblock()
-    // fn unblock()
-    // fn unblock()
-    // fn unblock()
-    // fn unblock()
-    // fn unblock() // fn unblock() // fn unblock() // fn unblock() // fn
-    // unblock()
-    {
+    pub(crate) fn unblock() {
         unsafe {
             use libc::*;
             use std::mem;
-- 
GitLab