Fixing remaining warnings and errors throughout
This commit is contained in:
parent
f9a32cdabc
commit
c765a8e7ad
@ -47,7 +47,7 @@ An example program that does this task reads like this:
|
||||
# #[allow(unused_imports)];
|
||||
use std::io::{BufferedReader, File};
|
||||
# mod BufferedReader {
|
||||
# use std::io::File;
|
||||
# use std::io::{File, IoResult};
|
||||
# use std::io::MemReader;
|
||||
# use std::io::BufferedReader;
|
||||
# static s : &'static [u8] = bytes!("1 2\n\
|
||||
@ -55,7 +55,7 @@ use std::io::{BufferedReader, File};
|
||||
# 789 123\n\
|
||||
# 45 67\n\
|
||||
# ");
|
||||
# pub fn new(_inner: Option<File>) -> BufferedReader<MemReader> {
|
||||
# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> {
|
||||
# BufferedReader::new(MemReader::new(s.to_owned()))
|
||||
# }
|
||||
# }
|
||||
@ -71,7 +71,6 @@ fn read_int_pairs() -> ~[(int,int)] {
|
||||
let mut pairs = ~[];
|
||||
|
||||
// Path takes a generic by-value, rather than by reference
|
||||
# let _g = std::io::ignore_io_error();
|
||||
let path = Path::new(&"foo.txt");
|
||||
let mut reader = BufferedReader::new(File::open(&path));
|
||||
|
||||
@ -245,7 +244,7 @@ and trapping its exit status using `task::try`:
|
||||
use std::io::{BufferedReader, File};
|
||||
use std::task;
|
||||
# mod BufferedReader {
|
||||
# use std::io::File;
|
||||
# use std::io::{File, IoResult};
|
||||
# use std::io::MemReader;
|
||||
# use std::io::BufferedReader;
|
||||
# static s : &'static [u8] = bytes!("1 2\n\
|
||||
@ -253,7 +252,7 @@ use std::task;
|
||||
# 789 123\n\
|
||||
# 45 67\n\
|
||||
# ");
|
||||
# pub fn new(_inner: Option<File>) -> BufferedReader<MemReader> {
|
||||
# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> {
|
||||
# BufferedReader::new(MemReader::new(s.to_owned()))
|
||||
# }
|
||||
# }
|
||||
@ -277,7 +276,6 @@ fn main() {
|
||||
|
||||
fn read_int_pairs() -> ~[(int,int)] {
|
||||
let mut pairs = ~[];
|
||||
# let _g = std::io::ignore_io_error();
|
||||
let path = Path::new(&"foo.txt");
|
||||
|
||||
let mut reader = BufferedReader::new(File::open(&path));
|
||||
@ -347,7 +345,7 @@ but similarly clear as the version that used `fail!` in the logic where the erro
|
||||
# #[allow(unused_imports)];
|
||||
use std::io::{BufferedReader, File};
|
||||
# mod BufferedReader {
|
||||
# use std::io::File;
|
||||
# use std::io::{File, IoResult};
|
||||
# use std::io::MemReader;
|
||||
# use std::io::BufferedReader;
|
||||
# static s : &'static [u8] = bytes!("1 2\n\
|
||||
@ -355,7 +353,7 @@ use std::io::{BufferedReader, File};
|
||||
# 789 123\n\
|
||||
# 45 67\n\
|
||||
# ");
|
||||
# pub fn new(_inner: Option<File>) -> BufferedReader<MemReader> {
|
||||
# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> {
|
||||
# BufferedReader::new(MemReader::new(s.to_owned()))
|
||||
# }
|
||||
# }
|
||||
@ -374,7 +372,6 @@ fn main() {
|
||||
|
||||
fn read_int_pairs() -> ~[(int,int)] {
|
||||
let mut pairs = ~[];
|
||||
# let _g = std::io::ignore_io_error();
|
||||
let path = Path::new(&"foo.txt");
|
||||
|
||||
let mut reader = BufferedReader::new(File::open(&path));
|
||||
@ -415,7 +412,7 @@ and replaces bad input lines with the pair `(-1,-1)`:
|
||||
# #[allow(unused_imports)];
|
||||
use std::io::{BufferedReader, File};
|
||||
# mod BufferedReader {
|
||||
# use std::io::File;
|
||||
# use std::io::{File, IoResult};
|
||||
# use std::io::MemReader;
|
||||
# use std::io::BufferedReader;
|
||||
# static s : &'static [u8] = bytes!("1 2\n\
|
||||
@ -423,7 +420,7 @@ use std::io::{BufferedReader, File};
|
||||
# 789 123\n\
|
||||
# 45 67\n\
|
||||
# ");
|
||||
# pub fn new(_inner: Option<File>) -> BufferedReader<MemReader> {
|
||||
# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> {
|
||||
# BufferedReader::new(MemReader::new(s.to_owned()))
|
||||
# }
|
||||
# }
|
||||
@ -447,7 +444,6 @@ fn main() {
|
||||
|
||||
fn read_int_pairs() -> ~[(int,int)] {
|
||||
let mut pairs = ~[];
|
||||
# let _g = std::io::ignore_io_error();
|
||||
let path = Path::new(&"foo.txt");
|
||||
|
||||
let mut reader = BufferedReader::new(File::open(&path));
|
||||
@ -489,7 +485,7 @@ Changing the condition's return type from `(int,int)` to `Option<(int,int)>` wil
|
||||
# #[allow(unused_imports)];
|
||||
use std::io::{BufferedReader, File};
|
||||
# mod BufferedReader {
|
||||
# use std::io::File;
|
||||
# use std::io::{IoResult, File};
|
||||
# use std::io::MemReader;
|
||||
# use std::io::BufferedReader;
|
||||
# static s : &'static [u8] = bytes!("1 2\n\
|
||||
@ -497,7 +493,7 @@ use std::io::{BufferedReader, File};
|
||||
# 789 123\n\
|
||||
# 45 67\n\
|
||||
# ");
|
||||
# pub fn new(_inner: Option<File>) -> BufferedReader<MemReader> {
|
||||
# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> {
|
||||
# BufferedReader::new(MemReader::new(s.to_owned()))
|
||||
# }
|
||||
# }
|
||||
@ -522,7 +518,6 @@ fn main() {
|
||||
|
||||
fn read_int_pairs() -> ~[(int,int)] {
|
||||
let mut pairs = ~[];
|
||||
# let _g = std::io::ignore_io_error();
|
||||
let path = Path::new(&"foo.txt");
|
||||
|
||||
let mut reader = BufferedReader::new(File::open(&path));
|
||||
@ -573,7 +568,7 @@ This can be encoded in the handler API by introducing a helper type: `enum Malfo
|
||||
# #[allow(unused_imports)];
|
||||
use std::io::{BufferedReader, File};
|
||||
# mod BufferedReader {
|
||||
# use std::io::File;
|
||||
# use std::io::{File, IoResult};
|
||||
# use std::io::MemReader;
|
||||
# use std::io::BufferedReader;
|
||||
# static s : &'static [u8] = bytes!("1 2\n\
|
||||
@ -581,7 +576,7 @@ use std::io::{BufferedReader, File};
|
||||
# 789 123\n\
|
||||
# 45 67\n\
|
||||
# ");
|
||||
# pub fn new(_inner: Option<File>) -> BufferedReader<MemReader> {
|
||||
# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> {
|
||||
# BufferedReader::new(MemReader::new(s.to_owned()))
|
||||
# }
|
||||
# }
|
||||
@ -615,7 +610,6 @@ fn main() {
|
||||
|
||||
fn read_int_pairs() -> ~[(int,int)] {
|
||||
let mut pairs = ~[];
|
||||
# let _g = std::io::ignore_io_error();
|
||||
let path = Path::new(&"foo.txt");
|
||||
|
||||
let mut reader = BufferedReader::new(File::open(&path));
|
||||
@ -696,7 +690,7 @@ a second condition and a helper function will suffice:
|
||||
# #[allow(unused_imports)];
|
||||
use std::io::{BufferedReader, File};
|
||||
# mod BufferedReader {
|
||||
# use std::io::File;
|
||||
# use std::io::{File, IoResult};
|
||||
# use std::io::MemReader;
|
||||
# use std::io::BufferedReader;
|
||||
# static s : &'static [u8] = bytes!("1 2\n\
|
||||
@ -704,7 +698,7 @@ use std::io::{BufferedReader, File};
|
||||
# 789 123\n\
|
||||
# 45 67\n\
|
||||
# ");
|
||||
# pub fn new(_inner: Option<File>) -> BufferedReader<MemReader> {
|
||||
# pub fn new(_inner: IoResult<File>) -> BufferedReader<MemReader> {
|
||||
# BufferedReader::new(MemReader::new(s.to_owned()))
|
||||
# }
|
||||
# }
|
||||
@ -752,7 +746,6 @@ fn parse_int(x: &str) -> int {
|
||||
|
||||
fn read_int_pairs() -> ~[(int,int)] {
|
||||
let mut pairs = ~[];
|
||||
# let _g = std::io::ignore_io_error();
|
||||
let path = Path::new(&"foo.txt");
|
||||
|
||||
let mut reader = BufferedReader::new(File::open(&path));
|
||||
|
@ -69,6 +69,7 @@ extern mod run_pass_stage2;
|
||||
use run_pass_stage2::*;
|
||||
use std::io;
|
||||
use std::io::Writer;
|
||||
#[allow(warnings)]
|
||||
fn main() {
|
||||
let mut out = io::stdout();
|
||||
"""
|
||||
|
@ -561,7 +561,7 @@ pub fn readdir(p: &CString) -> IoResult<~[Path]> {
|
||||
}
|
||||
more_files = FindNextFileW(find_handle, wfd_ptr as HANDLE);
|
||||
}
|
||||
FindClose(find_handle);
|
||||
assert!(FindClose(find_handle) != 0);
|
||||
free(wfd_ptr as *mut c_void);
|
||||
Ok(paths)
|
||||
} else {
|
||||
@ -683,7 +683,9 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
|
||||
ptr::mut_null())
|
||||
})
|
||||
};
|
||||
if handle == ptr::mut_null() { return Err(super::last_error()) }
|
||||
if handle as int == libc::INVALID_HANDLE_VALUE as int {
|
||||
return Err(super::last_error())
|
||||
}
|
||||
let ret = fill_utf16_buf_and_decode(|buf, sz| {
|
||||
unsafe {
|
||||
libc::GetFinalPathNameByHandleW(handle, buf as *u16, sz,
|
||||
@ -694,7 +696,7 @@ pub fn readlink(p: &CString) -> IoResult<Path> {
|
||||
Some(s) => Ok(Path::new(s)),
|
||||
None => Err(super::last_error()),
|
||||
};
|
||||
unsafe { libc::CloseHandle(handle) };
|
||||
assert!(unsafe { libc::CloseHandle(handle) } != 0);
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
@ -149,9 +149,8 @@ impl rtio::RtioProcess for Process {
|
||||
unsafe fn killpid(pid: pid_t, signal: int) -> Result<(), io::IoError> {
|
||||
match signal {
|
||||
io::process::PleaseExitSignal | io::process::MustDieSignal => {
|
||||
libc::funcs::extra::kernel32::TerminateProcess(
|
||||
cast::transmute(pid), 1);
|
||||
Ok(())
|
||||
let ret = libc::TerminateProcess(pid as libc::HANDLE, 1);
|
||||
super::mkerr_winbool(ret)
|
||||
}
|
||||
_ => Err(io::IoError {
|
||||
kind: io::OtherIoError,
|
||||
@ -255,9 +254,9 @@ fn spawn_process_os(prog: &str, args: &[~str],
|
||||
})
|
||||
});
|
||||
|
||||
CloseHandle(si.hStdInput);
|
||||
CloseHandle(si.hStdOutput);
|
||||
CloseHandle(si.hStdError);
|
||||
assert!(CloseHandle(si.hStdInput) != 0);
|
||||
assert!(CloseHandle(si.hStdOutput) != 0);
|
||||
assert!(CloseHandle(si.hStdError) != 0);
|
||||
|
||||
match create_err {
|
||||
Some(err) => return Err(err),
|
||||
@ -269,7 +268,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
|
||||
// able to close it later. We don't close the process handle however
|
||||
// because std::we want the process id to stay valid at least until the
|
||||
// calling code closes the process handle.
|
||||
CloseHandle(pi.hThread);
|
||||
assert!(CloseHandle(pi.hThread) != 0);
|
||||
|
||||
Ok(SpawnProcessResult {
|
||||
pid: pi.dwProcessId as pid_t,
|
||||
@ -576,9 +575,9 @@ fn with_dirp<T>(d: Option<&Path>, cb: |*libc::c_char| -> T) -> T {
|
||||
|
||||
#[cfg(windows)]
|
||||
fn free_handle(handle: *()) {
|
||||
unsafe {
|
||||
libc::funcs::extra::kernel32::CloseHandle(cast::transmute(handle));
|
||||
}
|
||||
assert!(unsafe {
|
||||
libc::CloseHandle(cast::transmute(handle)) != 0
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
@ -629,15 +628,15 @@ fn waitpid(pid: pid_t) -> p::ProcessExit {
|
||||
loop {
|
||||
let mut status = 0;
|
||||
if GetExitCodeProcess(process, &mut status) == FALSE {
|
||||
CloseHandle(process);
|
||||
assert!(CloseHandle(process) != 0);
|
||||
fail!("failure in GetExitCodeProcess: {}", os::last_os_error());
|
||||
}
|
||||
if status != STILL_ACTIVE {
|
||||
CloseHandle(process);
|
||||
assert!(CloseHandle(process) != 0);
|
||||
return p::ExitStatus(status as int);
|
||||
}
|
||||
if WaitForSingleObject(process, INFINITE) == WAIT_FAILED {
|
||||
CloseHandle(process);
|
||||
assert!(CloseHandle(process) != 0);
|
||||
fail!("failure in WaitForSingleObject: {}", os::last_os_error());
|
||||
}
|
||||
}
|
||||
|
@ -126,11 +126,11 @@ mod imp {
|
||||
}
|
||||
|
||||
pub fn signal(handle: HANDLE) {
|
||||
unsafe { SetEvent(handle); }
|
||||
assert!(unsafe { SetEvent(handle) != 0 });
|
||||
}
|
||||
|
||||
pub fn close(handle: HANDLE) {
|
||||
unsafe { CloseHandle(handle); }
|
||||
assert!(unsafe { CloseHandle(handle) != 0 });
|
||||
}
|
||||
|
||||
extern "system" {
|
||||
|
@ -62,8 +62,8 @@ fn helper(input: libc::HANDLE, messages: Port<Req>) {
|
||||
c.send(());
|
||||
match objs.iter().position(|&o| o == obj) {
|
||||
Some(i) => {
|
||||
objs.remove(i);
|
||||
chans.remove(i - 1);
|
||||
drop(objs.remove(i));
|
||||
drop(chans.remove(i - 1));
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
@ -83,8 +83,8 @@ fn helper(input: libc::HANDLE, messages: Port<Req>) {
|
||||
}
|
||||
};
|
||||
if remove {
|
||||
objs.remove(idx as uint);
|
||||
chans.remove(idx as uint - 1);
|
||||
drop(objs.remove(idx as uint));
|
||||
drop(chans.remove(idx as uint - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,7 +133,7 @@ impl rtio::RtioTimer for Timer {
|
||||
ptr::mut_null(), 0)
|
||||
}, 1);
|
||||
|
||||
unsafe { imp::WaitForSingleObject(self.obj, libc::INFINITE); }
|
||||
let _ = unsafe { imp::WaitForSingleObject(self.obj, libc::INFINITE) };
|
||||
}
|
||||
|
||||
fn oneshot(&mut self, msecs: u64) -> Port<()> {
|
||||
@ -173,7 +173,7 @@ impl rtio::RtioTimer for Timer {
|
||||
impl Drop for Timer {
|
||||
fn drop(&mut self) {
|
||||
self.remove();
|
||||
unsafe { libc::CloseHandle(self.obj); }
|
||||
assert!(unsafe { libc::CloseHandle(self.obj) != 0 });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,8 +241,8 @@ pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
|
||||
1u => {
|
||||
let ifile = matches.free[0].as_slice();
|
||||
if ifile == "-" {
|
||||
let src =
|
||||
str::from_utf8_owned(io::stdin().read_to_end()).unwrap();
|
||||
let contents = io::stdin().read_to_end().unwrap();
|
||||
let src = str::from_utf8_owned(contents).unwrap();
|
||||
(d::StrInput(src), None)
|
||||
} else {
|
||||
(d::FileInput(Path::new(ifile)), Some(Path::new(ifile)))
|
||||
|
@ -1160,12 +1160,12 @@ fn list_crate_deps(data: &[u8], out: &mut io::Writer) -> io::IoResult<()> {
|
||||
let r = get_crate_deps(data);
|
||||
for dep in r.iter() {
|
||||
let string = token::get_ident(dep.name.name);
|
||||
write!(out,
|
||||
"{} {}-{}-{}\n",
|
||||
dep.cnum,
|
||||
string.get(),
|
||||
dep.hash,
|
||||
dep.vers);
|
||||
if_ok!(write!(out,
|
||||
"{} {}-{}-{}\n",
|
||||
dep.cnum,
|
||||
string.get(),
|
||||
dep.hash,
|
||||
dep.vers));
|
||||
}
|
||||
|
||||
if_ok!(write!(out, "\n"));
|
||||
|
@ -48,7 +48,6 @@ impl PuritySpace {
|
||||
}
|
||||
|
||||
impl fmt::Show for clean::Generics {
|
||||
impl fmt::Default for clean::Generics {
|
||||
fn fmt(g: &clean::Generics, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if g.lifetimes.len() == 0 && g.type_params.len() == 0 { return Ok(()) }
|
||||
if_ok!(f.buf.write("<".as_bytes()));
|
||||
|
@ -804,13 +804,13 @@ impl<'a> fmt::Show for Item<'a> {
|
||||
fn fmt(it: &Item<'a>, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
match attr::find_stability(it.item.attrs.iter()) {
|
||||
Some(ref stability) => {
|
||||
write!(fmt.buf,
|
||||
if_ok!(write!(fmt.buf,
|
||||
"<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
|
||||
lvl = stability.level.to_str(),
|
||||
reason = match stability.text {
|
||||
Some(ref s) => (*s).clone(),
|
||||
None => InternedString::new(""),
|
||||
});
|
||||
}));
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
@ -477,16 +477,20 @@ will look like `"\\{"`.
|
||||
|
||||
*/
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
use prelude::*;
|
||||
|
||||
use cast;
|
||||
use char::Char;
|
||||
use container::Container;
|
||||
use io::MemWriter;
|
||||
use io;
|
||||
use str;
|
||||
use iter::{Iterator, range};
|
||||
use num::Signed;
|
||||
use option::{Option,Some,None};
|
||||
use repr;
|
||||
use result::{Ok, Err};
|
||||
use str::StrSlice;
|
||||
use str;
|
||||
use util;
|
||||
use vec::ImmutableVector;
|
||||
use vec;
|
||||
|
||||
// NOTE this is just because the `prelude::*` import above includes
|
||||
@ -494,19 +498,6 @@ use vec;
|
||||
#[cfg(stage0)]
|
||||
pub use Default = fmt::Show; // export required for `format!()` etc.
|
||||
|
||||
#[cfg(stage0)]
|
||||
use container::Container;
|
||||
#[cfg(stage0)]
|
||||
use iter::{Iterator, range};
|
||||
#[cfg(stage0)]
|
||||
use option::{Option,Some,None};
|
||||
#[cfg(stage0)]
|
||||
use vec::ImmutableVector;
|
||||
#[cfg(stage0)]
|
||||
use str::StrSlice;
|
||||
#[cfg(stage0)]
|
||||
use num::Signed;
|
||||
|
||||
pub mod parse;
|
||||
pub mod rt;
|
||||
|
||||
@ -628,7 +619,7 @@ macro_rules! uniform_fn_call_workaround {
|
||||
($( $name: ident, $trait_: ident; )*) => {
|
||||
$(
|
||||
#[doc(hidden)]
|
||||
pub fn $name<T: $trait_>(x: &T, fmt: &mut Formatter) {
|
||||
pub fn $name<T: $trait_>(x: &T, fmt: &mut Formatter) -> Result {
|
||||
$trait_::fmt(x, fmt)
|
||||
}
|
||||
)*
|
||||
|
@ -46,6 +46,7 @@ Some examples of obvious things you might want to do
|
||||
* Write a line to a file
|
||||
|
||||
```rust
|
||||
# #[allow(unused_must_use)];
|
||||
use std::io::File;
|
||||
|
||||
let mut file = File::create(&Path::new("message.txt"));
|
||||
@ -83,6 +84,7 @@ Some examples of obvious things you might want to do
|
||||
`write_str` and `write_line` methods.
|
||||
|
||||
```rust,should_fail
|
||||
# #[allow(unused_must_use)];
|
||||
use std::io::net::ip::SocketAddr;
|
||||
use std::io::net::tcp::TcpStream;
|
||||
|
||||
@ -188,6 +190,7 @@ be an error.
|
||||
If you wanted to handle the error though you might write:
|
||||
|
||||
```rust
|
||||
# #[allow(unused_must_use)];
|
||||
use std::io::File;
|
||||
|
||||
match File::create(&Path::new("diary.txt")).write(bytes!("Met a girl.\n")) {
|
||||
@ -360,7 +363,7 @@ pub struct IoError {
|
||||
detail: Option<~str>
|
||||
}
|
||||
|
||||
impl fmt::Default for IoError {
|
||||
impl fmt::Show for IoError {
|
||||
fn fmt(err: &IoError, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
if_ok!(fmt.buf.write_str(err.desc));
|
||||
match err.detail {
|
||||
@ -515,14 +518,13 @@ pub trait Reader {
|
||||
/// Returns any non-EOF error immediately. Previously read bytes are
|
||||
/// discarded when an error is returned.
|
||||
///
|
||||
/// When EOF is encountered, all bytes read up to that point are returned,
|
||||
/// but if 0 bytes have been read then the EOF error is returned.
|
||||
/// When EOF is encountered, all bytes read up to that point are returned.
|
||||
fn read_to_end(&mut self) -> IoResult<~[u8]> {
|
||||
let mut buf = vec::with_capacity(DEFAULT_BUF_SIZE);
|
||||
loop {
|
||||
match self.push_bytes(&mut buf, DEFAULT_BUF_SIZE) {
|
||||
Ok(()) => {}
|
||||
Err(ref e) if buf.len() > 0 && e.kind == EndOfFile => break,
|
||||
Err(ref e) if e.kind == EndOfFile => break,
|
||||
Err(e) => return Err(e)
|
||||
}
|
||||
}
|
||||
|
@ -192,9 +192,10 @@ mod test {
|
||||
|
||||
match stream.read(buf) {
|
||||
Ok(..) => fail!(),
|
||||
Err(ref e) if cfg!(windows) => assert_eq!(e.kind, NotConnected),
|
||||
Err(ref e) if cfg!(unix) => assert_eq!(e.kind, EndOfFile),
|
||||
Err(..) => fail!(),
|
||||
Err(ref e) => {
|
||||
assert!(e.kind == NotConnected || e.kind == EndOfFile,
|
||||
"unknown kind: {:?}", e.kind);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@ -217,9 +218,10 @@ mod test {
|
||||
|
||||
match stream.read(buf) {
|
||||
Ok(..) => fail!(),
|
||||
Err(ref e) if cfg!(windows) => assert_eq!(e.kind, NotConnected),
|
||||
Err(ref e) if cfg!(unix) => assert_eq!(e.kind, EndOfFile),
|
||||
Err(..) => fail!(),
|
||||
Err(ref e) => {
|
||||
assert!(e.kind == NotConnected || e.kind == EndOfFile,
|
||||
"unknown kind: {:?}", e.kind);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -203,6 +203,7 @@ mod test {
|
||||
fn test_io_signal_invalid_signum() {
|
||||
use io;
|
||||
use super::User1;
|
||||
use result::{Ok, Err};
|
||||
let mut s = Listener::new();
|
||||
let mut called = false;
|
||||
match s.register(User1) {
|
||||
|
@ -1535,6 +1535,7 @@ mod tests {
|
||||
assert!(*chunk.data == 0xbe);
|
||||
close(fd);
|
||||
}
|
||||
drop(chunk);
|
||||
|
||||
fs::unlink(&path).unwrap();
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ pub struct Display<'a, P> {
|
||||
}
|
||||
|
||||
impl<'a, P: GenericPath> fmt::Show for Display<'a, P> {
|
||||
fn fmt(d: &Display<P>, f: &mut fmt::Formatter) -> fmt::Display {
|
||||
fn fmt(d: &Display<P>, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
d.with_str(|s| f.pad(s))
|
||||
}
|
||||
}
|
||||
|
@ -588,8 +588,8 @@ impl BytesContainer for InternedString {
|
||||
}
|
||||
|
||||
impl fmt::Show for InternedString {
|
||||
fn fmt(obj: &InternedString, f: &mut fmt::Formatter) {
|
||||
write!(f.buf, "{}", obj.string.as_slice());
|
||||
fn fmt(obj: &InternedString, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f.buf, "{}", obj.string.as_slice())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,19 +299,34 @@ impl Printer {
|
||||
if !self.scan_stack_empty {
|
||||
self.check_stack(0);
|
||||
let left = self.token[self.left].clone();
|
||||
self.advance_left(left, self.size[self.left]);
|
||||
if_ok!(self.advance_left(left, self.size[self.left]));
|
||||
}
|
||||
Begin(b) => {
|
||||
if self.scan_stack_empty {
|
||||
self.left_total = 1;
|
||||
self.right_total = 1;
|
||||
self.left = 0u;
|
||||
self.right = 0u;
|
||||
} else { self.advance_right(); }
|
||||
debug!("pp Begin({})/buffer ~[{},{}]",
|
||||
b.offset, self.left, self.right);
|
||||
self.indent(0);
|
||||
Ok(())
|
||||
}
|
||||
Begin(b) => {
|
||||
if self.scan_stack_empty {
|
||||
self.left_total = 1;
|
||||
self.right_total = 1;
|
||||
self.left = 0u;
|
||||
self.right = 0u;
|
||||
} else { self.advance_right(); }
|
||||
debug!("pp Begin({})/buffer ~[{},{}]",
|
||||
b.offset, self.left, self.right);
|
||||
self.token[self.right] = t;
|
||||
self.size[self.right] = -self.right_total;
|
||||
self.scan_push(self.right);
|
||||
Ok(())
|
||||
}
|
||||
End => {
|
||||
if self.scan_stack_empty {
|
||||
debug!("pp End/print ~[{},{}]", self.left, self.right);
|
||||
self.print(t, 0)
|
||||
} else {
|
||||
debug!("pp End/buffer ~[{},{}]", self.left, self.right);
|
||||
self.advance_right();
|
||||
self.token[self.right] = t;
|
||||
self.size[self.right] = -self.right_total;
|
||||
self.size[self.right] = -1;
|
||||
self.scan_push(self.right);
|
||||
Ok(())
|
||||
}
|
||||
@ -330,12 +345,13 @@ impl Printer {
|
||||
self.token[self.right] = t;
|
||||
self.size[self.right] = -self.right_total;
|
||||
self.right_total += b.blank_space;
|
||||
Ok(())
|
||||
}
|
||||
String(ref s, len) => {
|
||||
if self.scan_stack_empty {
|
||||
debug!("pp String('{}')/print ~[{},{}]",
|
||||
*s, self.left, self.right);
|
||||
self.print(t.clone(), len);
|
||||
self.print(t.clone(), len)
|
||||
} else {
|
||||
debug!("pp String('{}')/buffer ~[{},{}]",
|
||||
*s, self.left, self.right);
|
||||
@ -343,8 +359,9 @@ impl Printer {
|
||||
self.token[self.right] = t.clone();
|
||||
self.size[self.right] = len;
|
||||
self.right_total += len;
|
||||
self.check_stream();
|
||||
self.check_stream()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn check_stream(&mut self) -> io::IoResult<()> {
|
||||
@ -360,8 +377,10 @@ impl Printer {
|
||||
}
|
||||
}
|
||||
let left = self.token[self.left].clone();
|
||||
self.advance_left(left, self.size[self.left]);
|
||||
if self.left != self.right { self.check_stream(); }
|
||||
if_ok!(self.advance_left(left, self.size[self.left]));
|
||||
if self.left != self.right {
|
||||
if_ok!(self.check_stream());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@ -405,7 +424,7 @@ impl Printer {
|
||||
debug!("advnce_left ~[{},{}], sizeof({})={}", self.left, self.right,
|
||||
self.left, L);
|
||||
if L >= 0 {
|
||||
self.print(x.clone(), L);
|
||||
let ret = self.print(x.clone(), L);
|
||||
match x {
|
||||
Break(b) => self.left_total += b.blank_space,
|
||||
String(_, len) => {
|
||||
@ -417,7 +436,7 @@ impl Printer {
|
||||
self.left += 1u;
|
||||
self.left %= self.buf_len;
|
||||
let left = self.token[self.left].clone();
|
||||
self.advance_left(left, self.size[self.left]);
|
||||
if_ok!(self.advance_left(left, self.size[self.left]));
|
||||
}
|
||||
ret
|
||||
} else {
|
||||
@ -477,7 +496,7 @@ impl Printer {
|
||||
}
|
||||
write!(self.out, "{}", s)
|
||||
}
|
||||
pub fn print(&mut self, x: Token, L: int) {
|
||||
pub fn print(&mut self, x: Token, L: int) -> io::IoResult<()> {
|
||||
debug!("print {} {} (remaining line space={})", tok_str(x.clone()), L,
|
||||
self.space);
|
||||
debug!("{}", buf_str(self.token.clone(),
|
||||
@ -587,16 +606,16 @@ pub fn end(p: &mut Printer) -> io::IoResult<()> { p.pretty_print(End) }
|
||||
|
||||
pub fn eof(p: &mut Printer) -> io::IoResult<()> { p.pretty_print(Eof) }
|
||||
|
||||
pub fn word(p: &mut Printer, wrd: &str) {
|
||||
p.pretty_print(String(/* bad */ wrd.to_str(), wrd.len() as int));
|
||||
pub fn word(p: &mut Printer, wrd: &str) -> io::IoResult<()> {
|
||||
p.pretty_print(String(/* bad */ wrd.to_str(), wrd.len() as int))
|
||||
}
|
||||
|
||||
pub fn huge_word(p: &mut Printer, wrd: &str) {
|
||||
p.pretty_print(String(/* bad */ wrd.to_str(), SIZE_INFINITY));
|
||||
pub fn huge_word(p: &mut Printer, wrd: &str) -> io::IoResult<()> {
|
||||
p.pretty_print(String(/* bad */ wrd.to_str(), SIZE_INFINITY))
|
||||
}
|
||||
|
||||
pub fn zero_word(p: &mut Printer, wrd: &str) {
|
||||
p.pretty_print(String(/* bad */ wrd.to_str(), 0));
|
||||
pub fn zero_word(p: &mut Printer, wrd: &str) -> io::IoResult<()> {
|
||||
p.pretty_print(String(/* bad */ wrd.to_str(), 0))
|
||||
}
|
||||
|
||||
pub fn spaces(p: &mut Printer, n: uint) -> io::IoResult<()> {
|
||||
|
@ -964,11 +964,7 @@ pub fn print_attribute(s: &mut State, attr: &ast::Attribute) -> io::IoResult<()>
|
||||
if_ok!(maybe_print_comment(s, attr.span.lo));
|
||||
if attr.node.is_sugared_doc {
|
||||
let comment = attr.value_str().unwrap();
|
||||
<<<<<<< HEAD
|
||||
word(&mut s.s, comment.get());
|
||||
=======
|
||||
if_ok!(word(&mut s.s, comment));
|
||||
>>>>>>> syntax: Remove io_error usage
|
||||
if_ok!(word(&mut s.s, comment.get()));
|
||||
} else {
|
||||
if_ok!(word(&mut s.s, "#["));
|
||||
if_ok!(print_meta_item(s, attr.meta()));
|
||||
@ -1139,24 +1135,7 @@ pub fn print_mac(s: &mut State, m: &ast::Mac) -> io::IoResult<()> {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub fn print_expr_vstore(s: &mut State, t: ast::ExprVstore) {
|
||||
=======
|
||||
pub fn print_vstore(s: &mut State, t: ast::Vstore) -> io::IoResult<()> {
|
||||
match t {
|
||||
ast::VstoreFixed(Some(i)) => word(&mut s.s, format!("{}", i)),
|
||||
ast::VstoreFixed(None) => word(&mut s.s, "_"),
|
||||
ast::VstoreUniq => word(&mut s.s, "~"),
|
||||
ast::VstoreBox => word(&mut s.s, "@"),
|
||||
ast::VstoreSlice(ref r) => {
|
||||
if_ok!(word(&mut s.s, "&"));
|
||||
print_opt_lifetime(s, r)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_expr_vstore(s: &mut State, t: ast::ExprVstore) -> io::IoResult<()> {
|
||||
>>>>>>> syntax: Remove io_error usage
|
||||
match t {
|
||||
ast::ExprVstoreUniq => word(&mut s.s, "~"),
|
||||
ast::ExprVstoreSlice => word(&mut s.s, "&"),
|
||||
@ -1557,51 +1536,27 @@ pub fn print_expr(s: &mut State, expr: &ast::Expr) -> io::IoResult<()> {
|
||||
} else {
|
||||
if_ok!(word(&mut s.s, "asm!"));
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
popen(s);
|
||||
print_string(s, a.asm.get(), a.asm_str_style);
|
||||
word_space(s, ":");
|
||||
for &(ref co, o) in a.outputs.iter() {
|
||||
print_string(s, co.get(), ast::CookedStr);
|
||||
popen(s);
|
||||
print_expr(s, o);
|
||||
pclose(s);
|
||||
word_space(s, ",");
|
||||
}
|
||||
word_space(s, ":");
|
||||
for &(ref co, o) in a.inputs.iter() {
|
||||
print_string(s, co.get(), ast::CookedStr);
|
||||
popen(s);
|
||||
print_expr(s, o);
|
||||
pclose(s);
|
||||
word_space(s, ",");
|
||||
}
|
||||
word_space(s, ":");
|
||||
print_string(s, a.clobbers.get(), ast::CookedStr);
|
||||
pclose(s);
|
||||
=======
|
||||
if_ok!(popen(s));
|
||||
if_ok!(print_string(s, a.asm, a.asm_str_style));
|
||||
if_ok!(print_string(s, a.asm.get(), a.asm_str_style));
|
||||
if_ok!(word_space(s, ":"));
|
||||
for &(co, o) in a.outputs.iter() {
|
||||
if_ok!(print_string(s, co, ast::CookedStr));
|
||||
for &(ref co, o) in a.outputs.iter() {
|
||||
if_ok!(print_string(s, co.get(), ast::CookedStr));
|
||||
if_ok!(popen(s));
|
||||
if_ok!(print_expr(s, o));
|
||||
if_ok!(pclose(s));
|
||||
if_ok!(word_space(s, ","));
|
||||
}
|
||||
if_ok!(word_space(s, ":"));
|
||||
for &(co, o) in a.inputs.iter() {
|
||||
if_ok!(print_string(s, co, ast::CookedStr));
|
||||
for &(ref co, o) in a.inputs.iter() {
|
||||
if_ok!(print_string(s, co.get(), ast::CookedStr));
|
||||
if_ok!(popen(s));
|
||||
if_ok!(print_expr(s, o));
|
||||
if_ok!(pclose(s));
|
||||
if_ok!(word_space(s, ","));
|
||||
}
|
||||
if_ok!(word_space(s, ":"));
|
||||
if_ok!(print_string(s, a.clobbers, ast::CookedStr));
|
||||
if_ok!(print_string(s, a.clobbers.get(), ast::CookedStr));
|
||||
if_ok!(pclose(s));
|
||||
>>>>>>> syntax: Remove io_error usage
|
||||
}
|
||||
ast::ExprMac(ref m) => if_ok!(print_mac(s, m)),
|
||||
ast::ExprParen(e) => {
|
||||
@ -1659,23 +1614,14 @@ pub fn print_decl(s: &mut State, decl: &ast::Decl) -> io::IoResult<()> {
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
pub fn print_ident(s: &mut State, ident: ast::Ident) {
|
||||
let string = token::get_ident(ident.name);
|
||||
word(&mut s.s, string.get());
|
||||
}
|
||||
|
||||
pub fn print_name(s: &mut State, name: ast::Name) {
|
||||
let string = token::get_ident(name);
|
||||
word(&mut s.s, string.get());
|
||||
=======
|
||||
pub fn print_ident(s: &mut State, ident: ast::Ident) -> io::IoResult<()> {
|
||||
word(&mut s.s, ident_to_str(&ident))
|
||||
let string = token::get_ident(ident.name);
|
||||
word(&mut s.s, string.get())
|
||||
}
|
||||
|
||||
pub fn print_name(s: &mut State, name: ast::Name) -> io::IoResult<()> {
|
||||
word(&mut s.s, interner_get(name))
|
||||
>>>>>>> syntax: Remove io_error usage
|
||||
let string = token::get_ident(name);
|
||||
word(&mut s.s, string.get())
|
||||
}
|
||||
|
||||
pub fn print_for_decl(s: &mut State, loc: &ast::Local,
|
||||
@ -2088,38 +2034,23 @@ pub fn print_generics(s: &mut State,
|
||||
pub fn print_meta_item(s: &mut State, item: &ast::MetaItem) -> io::IoResult<()> {
|
||||
if_ok!(ibox(s, indent_unit));
|
||||
match item.node {
|
||||
<<<<<<< HEAD
|
||||
ast::MetaWord(ref name) => word(&mut s.s, name.get()),
|
||||
ast::MetaNameValue(ref name, ref value) => {
|
||||
word_space(s, name.get());
|
||||
word_space(s, "=");
|
||||
print_literal(s, value);
|
||||
}
|
||||
ast::MetaList(ref name, ref items) => {
|
||||
word(&mut s.s, name.get());
|
||||
popen(s);
|
||||
commasep(s,
|
||||
Consistent,
|
||||
items.as_slice(),
|
||||
|p, &i| print_meta_item(p, i));
|
||||
pclose(s);
|
||||
=======
|
||||
ast::MetaWord(name) => { if_ok!(word(&mut s.s, name)); }
|
||||
ast::MetaNameValue(name, value) => {
|
||||
if_ok!(word_space(s, name));
|
||||
if_ok!(word_space(s, "="));
|
||||
if_ok!(print_literal(s, &value));
|
||||
}
|
||||
ast::MetaList(name, ref items) => {
|
||||
if_ok!(word(&mut s.s, name));
|
||||
if_ok!(popen(s));
|
||||
if_ok!(commasep(s,
|
||||
Consistent,
|
||||
items.as_slice(),
|
||||
|p, &i| print_meta_item(p, i)));
|
||||
if_ok!(pclose(s));
|
||||
>>>>>>> syntax: Remove io_error usage
|
||||
}
|
||||
ast::MetaWord(ref name) => {
|
||||
if_ok!(word(&mut s.s, name.get()));
|
||||
}
|
||||
ast::MetaNameValue(ref name, ref value) => {
|
||||
if_ok!(word_space(s, name.get()));
|
||||
if_ok!(word_space(s, "="));
|
||||
if_ok!(print_literal(s, value));
|
||||
}
|
||||
ast::MetaList(ref name, ref items) => {
|
||||
if_ok!(word(&mut s.s, name.get()));
|
||||
if_ok!(popen(s));
|
||||
if_ok!(commasep(s,
|
||||
Consistent,
|
||||
items.as_slice(),
|
||||
|p, &i| print_meta_item(p, i)));
|
||||
if_ok!(pclose(s));
|
||||
}
|
||||
}
|
||||
end(s)
|
||||
}
|
||||
@ -2171,17 +2102,10 @@ pub fn print_view_item(s: &mut State, item: &ast::ViewItem) -> io::IoResult<()>
|
||||
if_ok!(head(s, "extern mod"));
|
||||
if_ok!(print_ident(s, id));
|
||||
for &(ref p, style) in optional_path.iter() {
|
||||
<<<<<<< HEAD
|
||||
space(&mut s.s);
|
||||
word(&mut s.s, "=");
|
||||
space(&mut s.s);
|
||||
print_string(s, p.get(), style);
|
||||
=======
|
||||
if_ok!(space(&mut s.s));
|
||||
if_ok!(word(&mut s.s, "="));
|
||||
if_ok!(space(&mut s.s));
|
||||
if_ok!(print_string(s, *p, style));
|
||||
>>>>>>> syntax: Remove io_error usage
|
||||
if_ok!(print_string(s, p.get(), style));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2373,88 +2297,54 @@ pub fn print_literal(s: &mut State, lit: &ast::Lit) -> io::IoResult<()> {
|
||||
_ => ()
|
||||
}
|
||||
match lit.node {
|
||||
<<<<<<< HEAD
|
||||
ast::LitStr(ref st, style) => print_string(s, st.get(), style),
|
||||
ast::LitChar(ch) => {
|
||||
let mut res = ~"'";
|
||||
char::from_u32(ch).unwrap().escape_default(|c| res.push_char(c));
|
||||
res.push_char('\'');
|
||||
word(&mut s.s, res);
|
||||
word(&mut s.s, res)
|
||||
}
|
||||
ast::LitInt(i, t) => {
|
||||
if i < 0_i64 {
|
||||
word(&mut s.s,
|
||||
~"-" + (-i as u64).to_str_radix(10u)
|
||||
+ ast_util::int_ty_to_str(t));
|
||||
+ ast_util::int_ty_to_str(t))
|
||||
} else {
|
||||
word(&mut s.s,
|
||||
(i as u64).to_str_radix(10u)
|
||||
+ ast_util::int_ty_to_str(t));
|
||||
=======
|
||||
ast::LitStr(st, style) => print_string(s, st, style),
|
||||
ast::LitChar(ch) => {
|
||||
let mut res = ~"'";
|
||||
char::from_u32(ch).unwrap().escape_default(|c| res.push_char(c));
|
||||
res.push_char('\'');
|
||||
word(&mut s.s, res)
|
||||
+ ast_util::int_ty_to_str(t))
|
||||
}
|
||||
ast::LitInt(i, t) => {
|
||||
if i < 0_i64 {
|
||||
word(&mut s.s, ~"-" + (-i as u64).to_str_radix(10u)
|
||||
+ ast_util::int_ty_to_str(t))
|
||||
} else {
|
||||
word(&mut s.s, (i as u64).to_str_radix(10u)
|
||||
+ ast_util::int_ty_to_str(t))
|
||||
}
|
||||
>>>>>>> syntax: Remove io_error usage
|
||||
}
|
||||
ast::LitUint(u, t) => {
|
||||
word(&mut s.s, u.to_str_radix(10u) + ast_util::uint_ty_to_str(t))
|
||||
}
|
||||
ast::LitIntUnsuffixed(i) => {
|
||||
if i < 0_i64 {
|
||||
word(&mut s.s, ~"-" + (-i as u64).to_str_radix(10u))
|
||||
} else {
|
||||
word(&mut s.s, (i as u64).to_str_radix(10u))
|
||||
}
|
||||
}
|
||||
ast::LitFloat(f, t) => {
|
||||
word(&mut s.s, f.to_owned() + ast_util::float_ty_to_str(t))
|
||||
}
|
||||
ast::LitFloatUnsuffixed(f) => word(&mut s.s, f),
|
||||
ast::LitNil => word(&mut s.s, "()"),
|
||||
ast::LitBool(val) => {
|
||||
if val { word(&mut s.s, "true") } else { word(&mut s.s, "false") }
|
||||
}
|
||||
ast::LitBinary(arr) => {
|
||||
if_ok!(ibox(s, indent_unit));
|
||||
if_ok!(word(&mut s.s, "["));
|
||||
if_ok!(commasep_cmnt(s, Inconsistent, arr,
|
||||
|s, u| word(&mut s.s, format!("{}", *u)),
|
||||
|_| lit.span));
|
||||
if_ok!(word(&mut s.s, "]"));
|
||||
end(s)
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
ast::LitUint(u, t) => {
|
||||
word(&mut s.s,
|
||||
u.to_str_radix(10u)
|
||||
+ ast_util::uint_ty_to_str(t))
|
||||
}
|
||||
ast::LitIntUnsuffixed(i) => {
|
||||
if i < 0_i64 {
|
||||
word(&mut s.s, ~"-" + (-i as u64).to_str_radix(10u))
|
||||
} else {
|
||||
word(&mut s.s, (i as u64).to_str_radix(10u))
|
||||
}
|
||||
}
|
||||
|
||||
ast::LitFloat(ref f, t) => {
|
||||
word(&mut s.s, f.get() + ast_util::float_ty_to_str(t));
|
||||
word(&mut s.s, f.get() + ast_util::float_ty_to_str(t))
|
||||
}
|
||||
ast::LitFloatUnsuffixed(ref f) => word(&mut s.s, f.get()),
|
||||
ast::LitNil => word(&mut s.s, "()"),
|
||||
ast::LitBool(val) => {
|
||||
if val { word(&mut s.s, "true"); } else { word(&mut s.s, "false"); }
|
||||
if val { word(&mut s.s, "true") } else { word(&mut s.s, "false") }
|
||||
}
|
||||
ast::LitBinary(ref arr) => {
|
||||
ibox(s, indent_unit);
|
||||
word(&mut s.s, "[");
|
||||
commasep_cmnt(s, Inconsistent, *arr.borrow(), |s, u| word(&mut s.s, format!("{}", *u)),
|
||||
|_| lit.span);
|
||||
word(&mut s.s, "]");
|
||||
end(s);
|
||||
if_ok!(ibox(s, indent_unit));
|
||||
if_ok!(word(&mut s.s, "["));
|
||||
if_ok!(commasep_cmnt(s, Inconsistent, *arr.borrow(),
|
||||
|s, u| word(&mut s.s, format!("{}", *u)),
|
||||
|_| lit.span));
|
||||
if_ok!(word(&mut s.s, "]"));
|
||||
end(s)
|
||||
}
|
||||
=======
|
||||
>>>>>>> syntax: Remove io_error usage
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,21 @@
|
||||
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
||||
html_root_url = "http://static.rust-lang.org/doc/master")];
|
||||
|
||||
#[feature(macro_rules)];
|
||||
#[deny(non_camel_case_types)];
|
||||
#[allow(missing_doc)];
|
||||
|
||||
use std::os;
|
||||
use std::io;
|
||||
use terminfo::TermInfo;
|
||||
use terminfo::searcher::open;
|
||||
use terminfo::parser::compiled::{parse, msys_terminfo};
|
||||
use terminfo::parm::{expand, Number, Variables};
|
||||
|
||||
macro_rules! if_ok (
|
||||
($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
|
||||
)
|
||||
|
||||
pub mod terminfo;
|
||||
|
||||
// FIXME (#2807): Windows support.
|
||||
|
@ -8,11 +8,12 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::io;
|
||||
use std::io::BufferedWriter;
|
||||
|
||||
struct DummyWriter;
|
||||
impl Writer for DummyWriter {
|
||||
fn write(&mut self, _: &[u8]) {}
|
||||
fn write(&mut self, _: &[u8]) -> io::IoResult<()> { Ok(()) }
|
||||
}
|
||||
|
||||
static ITER: int = 50;
|
||||
|
@ -36,11 +36,12 @@ fn make_complements() -> [u8, ..256] {
|
||||
|
||||
fn main() {
|
||||
let complements = make_complements();
|
||||
let mut data = if std::os::getenv("RUST_BENCH").is_some() {
|
||||
let data = if std::os::getenv("RUST_BENCH").is_some() {
|
||||
File::open(&Path::new("shootout-k-nucleotide.data")).read_to_end()
|
||||
} else {
|
||||
stdin().read_to_end()
|
||||
};
|
||||
let mut data = data.unwrap();
|
||||
|
||||
for seq in data.mut_split(|c| *c == '>' as u8) {
|
||||
// skip header and last \n
|
||||
|
Loading…
x
Reference in New Issue
Block a user