Przeglądaj źródła

~/.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 lat temu
rodzic
commit
5686efb98e
1 zmienionych plików z 8 dodań i 6 usunięć
  1. 8 6
      .bin/up.rs

+ 8 - 6
.bin/up.rs

1
use std::os;
2
1
fn main() {
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
		cwd = os::getcwd();
7
		cwd = os::getcwd();
6
		if Path(path).exists() {
7
			io::println(cwd.to_str());
8
		if path.exists() {
9
			println!("{}", cwd.display());
8
			return;
10
			return;
9
		} else {
11
		} else {
10
			os::change_dir(&Path(".."));
12
			os::change_dir(&Path::new(".."));
11
		}
13
		}
12
	}
14
	}
13
15