Просмотр исходного кода

~/.bin/up.rs: fix compilation with new rust.

ugh, that was quite a thing. i guess that borrowing thing is still
confusing. why can't i get a read-only non-& value out of a vector?
and why does .as_slice() work?
Lucas Stadler лет назад: 11
Родитель
Сommit
5686efb98e
1 измененных файлов с 8 добавлено и 6 удалено
  1. 8 6
      .bin/up.rs

+ 8 - 6
.bin/up.rs

@ -1,13 +1,15 @@
1
use std::os;
2
1 3
fn main() {
2
	let path = copy os::args()[1];
3
	let mut cwd = Path("");
4
	while cwd != Path("/") {
4
	let path = Path::new(os::args().get(1).as_slice());
5
	let mut cwd = Path::new("");
6
	while cwd != Path::new("/") {
5 7
		cwd = os::getcwd();
6
		if Path(path).exists() {
7
			io::println(cwd.to_str());
8
		if path.exists() {
9
			println!("{}", cwd.display());
8 10
			return;
9 11
		} else {
10
			os::change_dir(&Path(".."));
12
			os::change_dir(&Path::new(".."));
11 13
		}
12 14
	}
13 15