From 0cdde6e5e015ee6f6d9381ab624a312af7c9b069 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 27 Jan 2015 22:52:32 -0800 Subject: std: Stabilize FromStr and parse This commits adds an associated type to the `FromStr` trait representing an error payload for parses which do not succeed. The previous return value, `Option` did not allow for this form of payload. After the associated type was added, the following attributes were applied: * `FromStr` is now stable * `FromStr::Err` is now stable * `FromStr::from_str` is now stable * `StrExt::parse` is now stable * `FromStr for bool` is now stable * `FromStr for $float` is now stable * `FromStr for $integral` is now stable * Errors returned from stable `FromStr` implementations are stable * Errors implement `Display` and `Error` (both impl blocks being `#[stable]`) Closes #15138 --- src/libstd/rt/util.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/libstd/rt') diff --git a/src/libstd/rt/util.rs b/src/libstd/rt/util.rs index 4023a0a4c10..f5727a38b69 100644 --- a/src/libstd/rt/util.rs +++ b/src/libstd/rt/util.rs @@ -51,7 +51,7 @@ pub fn min_stack() -> uint { 0 => {} n => return n - 1, } - let amt = os::getenv("RUST_MIN_STACK").and_then(|s| s.parse()); + let amt = os::getenv("RUST_MIN_STACK").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 @@ -64,7 +64,7 @@ pub fn min_stack() -> uint { pub fn default_sched_threads() -> uint { match os::getenv("RUST_THREADS") { Some(nstr) => { - let opt_n: Option = nstr.parse(); + let opt_n: Option = nstr.parse().ok(); match opt_n { Some(n) if n > 0 => n, _ => panic!("`RUST_THREADS` is `{}`, should be a positive integer", nstr) -- cgit 1.4.1-3-g733a5