Forráskód Böngészése

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.
Zbigniew Siciarz 10 éve
szülő
commit
22c50901ff
1 módosított fájl, 2 hozzáadás és 2 törlés
  1. 2 2
      src/bigint.rs

+ 2 - 2
src/bigint.rs

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