#![feature(libc)]
extern crate libc;



fn isatty() -> bool {
    let isatty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0;
    isatty
}

pub fn readline() -> Option<String> {
    if isatty() {
        Some(buffer)
    } else {
        None
    }
}




#![feature(libc)]
extern crate libc;

pub fn readline() -> Option<String> {
    // Buffer to hold readline input
    let buffer = String::new();

    let isatty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0; 
    if isatty  {
        println!("stdin is a tty");
    } else {
        println!("stdin is not a tty");
    }

    buffer
}

--- 
+++ 
@@ -1,16 +1,20 @@
 #![feature(libc)]
 extern crate libc;
 
+
+
+fn isatty() -> bool {
+    let isatty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0;
+    isatty
+}
+
 pub fn readline() -> Option<String> {
-    // Buffer to hold readline input
-    let buffer = String::new();
+    if isatty() {
+        Some(buffer)
+    } else {
+        None
+    }
+}
 
-    let isatty = unsafe { libc::isatty(libc::STDIN_FILENO as i32) } != 0; 
-    if isatty  {
-        println!("stdin is a tty");
-    } else {
-        println!("stdin is not a tty");
-    }
 
-    buffer
-}
+
Split out tty check to a separate function
