1
Fork 0

std: Tweak the std::env OsString/String interface

This commit tweaks the interface of the `std::env` module to make it more
ergonomic for common usage:

* `env::var` was renamed to `env::var_os`
* `env::var_string` was renamed to `env::var`
* `env::args` was renamed to `env::args_os`
* `env::args` was re-added as a panicking iterator over string values
* `env::vars` was renamed to `env::vars_os`
* `env::vars` was re-added as a panicking iterator over string values.

This should make common usage (e.g. unicode values everywhere) more ergonomic
as well as "the default". This is also a breaking change due to the differences
of what's yielded from each of these functions, but migration should be fairly
easy as the defaults operate over `String` which is a common type to use.

[breaking-change]
This commit is contained in:
Alex Crichton 2015-02-11 11:47:53 -08:00
parent 446bc899b2
commit a828e79480
21 changed files with 169 additions and 87 deletions

View file

@ -122,10 +122,10 @@ struct Output {
}
pub fn main() {
static STACK_SIZE: uint = 32000000; // 32MB
const STACK_SIZE: usize = 32000000; // 32MB
let res = std::thread::Builder::new().stack_size(STACK_SIZE).scoped(move || {
let s = env::args().map(|s| s.into_string().unwrap());
main_args(&s.collect::<Vec<_>>())
let s = env::args().collect::<Vec<_>>();
main_args(&s)
}).join();
env::set_exit_status(res.ok().unwrap() as i32);
}