De-~[] Reader and Writer

There's a little more allocation here and there now since
from_utf8_owned can't be used with Vec.
This commit is contained in:
Steven Fackler 2014-03-26 09:24:16 -07:00
parent 94a055c729
commit d0e60b72ee
27 changed files with 117 additions and 108 deletions

View file

@ -44,7 +44,7 @@ fn main() {
};
let mut data = data.unwrap();
for seq in data.mut_split(|c| *c == '>' as u8) {
for seq in data.as_mut_slice().mut_split(|c| *c == '>' as u8) {
// skip header and last \n
let begin = match seq.iter().position(|c| *c == '\n' as u8) {
None => continue,
@ -80,5 +80,5 @@ fn main() {
}
}
stdout().write(data).unwrap();
stdout().write(data.as_slice()).unwrap();
}

View file

@ -58,7 +58,7 @@ fn main() {
// rustc is passed to us with --out-dir and -L etc., so we
// can't exec it directly
let result = Process::output("sh", [~"-c", rustc + " " + main_file_str]).unwrap();
let err = str::from_utf8_lossy(result.error);
let err = str::from_utf8_lossy(result.error.as_slice());
// positive test so that this test will be updated when the
// compiler changes.

View file

@ -55,7 +55,7 @@ fn main() {
// can't exec it directly
let result = Process::output("sh", [~"-c", rustc + " " + main_file_str]).unwrap();
let err = str::from_utf8_lossy(result.error);
let err = str::from_utf8_lossy(result.error.as_slice());
// the span should end the line (e.g no extra ~'s)
let expected_span = "^" + "~".repeat(n - 1) + "\n";

View file

@ -53,7 +53,7 @@ fn runtest(me: &str) {
}).unwrap();
let out = p.wait_with_output();
assert!(!out.status.success());
let s = str::from_utf8(out.error).unwrap();
let s = str::from_utf8(out.error.as_slice()).unwrap();
assert!(s.contains("stack backtrace") && s.contains("foo::h"),
"bad output: {}", s);
@ -65,7 +65,7 @@ fn runtest(me: &str) {
}).unwrap();
let out = p.wait_with_output();
assert!(!out.status.success());
let s = str::from_utf8(out.error).unwrap();
let s = str::from_utf8(out.error.as_slice()).unwrap();
assert!(!s.contains("stack backtrace") && !s.contains("foo::h"),
"bad output2: {}", s);
@ -77,7 +77,7 @@ fn runtest(me: &str) {
}).unwrap();
let out = p.wait_with_output();
assert!(!out.status.success());
let s = str::from_utf8(out.error).unwrap();
let s = str::from_utf8(out.error.as_slice()).unwrap();
assert!(s.contains("stack backtrace") && s.contains("double::h"),
"bad output3: {}", s);
@ -90,7 +90,7 @@ fn runtest(me: &str) {
}).unwrap();
let out = p.wait_with_output();
assert!(!out.status.success());
let s = str::from_utf8(out.error).unwrap();
let s = str::from_utf8(out.error.as_slice()).unwrap();
let mut i = 0;
for _ in range(0, 2) {
i += s.slice_from(i + 10).find_str("stack backtrace").unwrap() + 10;

View file

@ -43,12 +43,12 @@ fn main() {
} else {
let silent = Process::output(args[0], [~"silent"]).unwrap();
assert!(!silent.status.success());
let error = str::from_utf8_lossy(silent.error);
let error = str::from_utf8_lossy(silent.error.as_slice());
assert!(error.as_slice().contains("has overflowed its stack"));
let loud = Process::output(args[0], [~"loud"]).unwrap();
assert!(!loud.status.success());
let error = str::from_utf8_lossy(silent.error);
let error = str::from_utf8_lossy(silent.error.as_slice());
assert!(error.as_slice().contains("has overflowed its stack"));
}
}