From a828e7948069f310dc5b33be8edb65e5e8e0cf9a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 11 Feb 2015 11:47:53 -0800 Subject: 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] --- src/libstd/rt/backtrace.rs | 2 +- src/libstd/rt/util.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstd/rt') diff --git a/src/libstd/rt/backtrace.rs b/src/libstd/rt/backtrace.rs index 2af5a486d0d..ced84d7551e 100644 --- a/src/libstd/rt/backtrace.rs +++ b/src/libstd/rt/backtrace.rs @@ -29,7 +29,7 @@ pub fn log_enabled() -> bool { _ => {} } - let val = match env::var("RUST_BACKTRACE") { + let val = match env::var_os("RUST_BACKTRACE") { Some(..) => 2, None => 1, }; diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index 703dca4d29b..bb57d19ed26 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -52,7 +52,7 @@ pub fn min_stack() -> uint { 0 => {} n => return n - 1, } - let amt = env::var_string("RUST_MIN_STACK").ok().and_then(|s| s.parse().ok()); + let amt = env::var("RUST_MIN_STACK").ok().and_then(|s| s.parse().ok()); let amt = amt.unwrap_or(2 * 1024 * 1024); // 0 is our sentinel value, so ensure that we'll never see 0 after // initialization has run @@ -63,7 +63,7 @@ pub fn min_stack() -> uint { /// Get's the number of scheduler threads requested by the environment /// either `RUST_THREADS` or `num_cpus`. pub fn default_sched_threads() -> uint { - match env::var_string("RUST_THREADS") { + match env::var("RUST_THREADS") { Ok(nstr) => { let opt_n: Option = nstr.parse().ok(); match opt_n { -- cgit 1.4.1-3-g733a5