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)) }