From 22c50901ff53a9809737b5268b90189d7659ab1e Mon Sep 17 00:00:00 2001 From: Zbigniew Siciarz Date: Tue, 23 Dec 2014 17:09:22 +0100 Subject: [PATCH] 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. --- src/bigint.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bigint.rs b/src/bigint.rs index a3f12b9..9fa4c0f 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -851,7 +851,7 @@ impl BigUint { /// Creates and initializes a `BigUint`. #[inline] pub fn parse_bytes(buf: &[u8], radix: uint) -> Option { - 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 { - 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)) }