Remove unnecessary BasicTerminal
authorYehuda Katz <wycats@gmail.com>
Wed, 28 May 2014 05:06:38 +0000 (22:06 -0700)
committerYehuda Katz <wycats@gmail.com>
Wed, 28 May 2014 05:06:38 +0000 (22:06 -0700)
src/cargo/core/shell.rs

index 7bcdbddd621d7ff95bdb992b6ab0fd8ac2429009..d6e1125692b00ce9b1d187d4ed0f209071abb032 100644 (file)
@@ -11,7 +11,7 @@ pub struct ShellConfig {
 }
 
 enum AdequateTerminal<T> {
-    NoColor(BasicTerminal<T>),
+    NoColor(T),
     Color(Box<Terminal<T>>)
 }
 
@@ -26,7 +26,7 @@ impl<T: Writer + Send> Shell<T> {
             let term: Option<term::TerminfoTerminal<T>> = Terminal::new(out);
             term.map(|t| Shell { terminal: Color(box t as Box<Terminal<T>>), config: config })
         } else {
-            Some(Shell { terminal: NoColor(BasicTerminal { writer: out }), config: config })
+            Some(Shell { terminal: NoColor(out), config: config })
         }
     }
 
@@ -56,35 +56,35 @@ impl<T: Writer + Send> Terminal<T> for Shell<T> {
     fn fg(&mut self, color: color::Color) -> IoResult<bool> {
         match self.terminal {
             Color(ref mut c) => c.fg(color),
-            NoColor(ref mut n) => n.fg(color)
+            NoColor(_) => Ok(false)
         }
     }
 
     fn bg(&mut self, color: color::Color) -> IoResult<bool> {
         match self.terminal {
             Color(ref mut c) => c.bg(color),
-            NoColor(ref mut n) => n.bg(color)
+            NoColor(_) => Ok(false)
         }
     }
 
     fn attr(&mut self, attr: Attr) -> IoResult<bool> {
         match self.terminal {
             Color(ref mut c) => c.attr(attr),
-            NoColor(ref mut n) => n.attr(attr)
+            NoColor(_) => Ok(false)
         }
     }
 
     fn supports_attr(&self, attr: Attr) -> bool {
         match self.terminal {
             Color(ref c) => c.supports_attr(attr),
-            NoColor(ref n) => n.supports_attr(attr)
+            NoColor(_) => false
         }
     }
 
     fn reset(&mut self) -> IoResult<()> {
         match self.terminal {
             Color(ref mut c) => c.reset(),
-            NoColor(ref mut n) => n.reset()
+            NoColor(_) => Ok(())
         }
     }
 
@@ -95,14 +95,14 @@ impl<T: Writer + Send> Terminal<T> for Shell<T> {
     fn get_ref<'a>(&'a self) -> &'a T {
         match self.terminal {
             Color(ref c) => c.get_ref(),
-            NoColor(ref n) => n.get_ref()
+            NoColor(ref w) => w
         }
     }
 
     fn get_mut<'a>(&'a mut self) -> &'a mut T {
         match self.terminal {
             Color(ref mut c) => c.get_mut(),
-            NoColor(ref mut n) => n.get_mut()
+            NoColor(ref mut w) => w
         }
     }
 }
@@ -122,56 +122,3 @@ impl<T: Writer + Send> Writer for Shell<T> {
         }
     }
 }
-
-pub struct BasicTerminal<T> {
-    writer: T
-}
-
-impl<T: Writer + Send> Terminal<T> for BasicTerminal<T> {
-    fn new(out: T) -> Option<BasicTerminal<T>> {
-        Some(BasicTerminal { writer: out })
-    }
-
-    fn fg(&mut self, _: Color) -> IoResult<bool> {
-        Ok(false)
-    }
-
-    fn bg(&mut self, _: Color) -> IoResult<bool> {
-        Ok(false)
-    }
-
-    fn attr(&mut self, _: Attr) -> IoResult<bool> {
-        Ok(false)
-    }
-
-    fn supports_attr(&self, _: Attr) -> bool {
-        false
-    }
-
-    fn reset(&mut self) -> IoResult<()> {
-        Ok(())
-    }
-
-    fn unwrap(self) -> T {
-        self.writer
-    }
-
-    fn get_ref<'a>(&'a self) -> &'a T {
-        &self.writer
-    }
-
-    fn get_mut<'a>(&'a mut self) -> &'a mut T {
-        &mut self.writer
-    }
-}
-
-impl<T: Writer + Send> Writer for BasicTerminal<T> {
-    fn write(&mut self, buf: &[u8]) -> IoResult<()> {
-        self.writer.write(buf)
-    }
-
-    fn flush(&mut self) -> IoResult<()> {
-        self.writer.flush()
-    }
-}
-