Hi all,
i would like to parse a file, line by line, and when a line finishes with
'\', the next line is considered as the continuation of the current line.
I Would like to wtite something like this
let mut multi = ~"";
for line in BufferedReader::new(reader).lines() {
match line {
Ok(l) => {
multi = multi.append(l);
let mut buf = &*multi
// we operate on buf
// .................
if buf.ends_with("\\") { multi = buf.slice_to(buf.len()-1).to_owned();
continue; }
// we operate on buf
// .................
}
Err(e) => { t=Err(e); break; }
}
multi=~"";
}
in fact, i have to write this :
let mut multi = ~"";
for line in BufferedReader::new(reader).lines() {
match line {
Ok(l) => {
multi = multi.append(l);
let multic = multi.clone();
let mut buf = multic.slice_from(0); // How to convert ~str to &str ??? &*
is refused
// we operate on buf
// .................
if buf.ends_with("\\") { multi = buf.slice_to(buf.len()-1).to_owned();
continue; }
// we operate on buf
// .................
}
Err(e) => { t=Err(e); break; }
}
multi=~"";
}
any better way to do ?
Thanks
--
Christophe
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev