From 4d21e7f3e40bb204be1fa7f8ef699244a46229ef Mon Sep 17 00:00:00 2001 From: Florian Gilcher Date: Tue, 8 Mar 2016 11:04:09 +0100 Subject: [PATCH 1/2] Replace unstable 'chars' by 'bytes' As this is a paththrough function and all important control chars are in the byte range, chars is not necessary. --- src/extra.rs | 8 ++++---- src/lib.rs | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/extra.rs b/src/extra.rs index eacd4d8..36602b4 100644 --- a/src/extra.rs +++ b/src/extra.rs @@ -15,12 +15,12 @@ impl ReadExt for R { let _raw = try!(writer.into_raw_mode()); let mut string = String::with_capacity(30); - for c in self.chars() { + for c in self.bytes() { match c { Err(_) => return Err(TerminalError::StdinError), - Ok('\0') | Ok('\x03') | Ok('\x04') => return Ok(None), - Ok('\n') | Ok('\r') => return Ok(Some(string)), - Ok(c) => string.push(c), + Ok(b'\0') | Ok(b'\x03') | Ok(b'\x04') => return Ok(None), + Ok(b'\n') | Ok(b'\r') => return Ok(Some(string)), + Ok(c) => string.push(c as char), } } diff --git a/src/lib.rs b/src/lib.rs index c29790d..11c007f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(io)] #![feature(libc)] #[warn(missing_docs)] From 5a11c6d2c7f22c93976d0671ae79a4c25a00b052 Mon Sep 17 00:00:00 2001 From: Florian Gilcher Date: Tue, 8 Mar 2016 11:07:34 +0100 Subject: [PATCH 2/2] Use libc from crates.io --- Cargo.toml | 1 + src/lib.rs | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ada7bca..19101a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,4 @@ version = "0.1.0" authors = ["Ticki "] [dependencies] +libc = "0.2.8" diff --git a/src/lib.rs b/src/lib.rs index 11c007f..ae67d23 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(libc)] - #[warn(missing_docs)] #[cfg(not(target_os = "redox"))]