Convert Result to Option in parse_bytes.

`str::from_utf8` changed its return type to `Result`, but
`num::FromStrRadix::from_str_radix` still returns an `Option`. In this case
discarding the `Err` variant with `ok()` seems fine to me.
This commit is contained in:
Zbigniew Siciarz 2014-12-23 17:09:22 +01:00
parent f95afeb57e
commit 22c50901ff
1 changed files with 2 additions and 2 deletions

View File

@ -851,7 +851,7 @@ impl BigUint {
/// Creates and initializes a `BigUint`.
#[inline]
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<BigUint> {
str::from_utf8(buf).and_then(|s| FromStrRadix::from_str_radix(s, radix))
str::from_utf8(buf).ok().and_then(|s| FromStrRadix::from_str_radix(s, radix))
}
#[inline]
@ -1535,7 +1535,7 @@ impl BigInt {
/// Creates and initializes a `BigInt`.
#[inline]
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<BigInt> {
str::from_utf8(buf).and_then(|s| FromStrRadix::from_str_radix(s, radix))
str::from_utf8(buf).ok().and_then(|s| FromStrRadix::from_str_radix(s, radix))
}