rust/src/test/run-pass/match-drop-strs-issue-4541.rs

27 lines
498 B
Rust
Raw Normal View History

// Tests a tricky scenario involving string matching,
// copying, and moving to ensure that we don't segfault
// or double-free, as we were wont to do in the past.
use std::os;
fn parse_args() -> ~str {
let args = os::args();
let mut n = 0;
while n < args.len() {
2013-07-12 23:05:59 -05:00
match args[n].clone() {
~"-v" => (),
s => {
return s;
}
}
n += 1;
}
return ~""
}
pub fn main() {
println!("{}", parse_args());
}