From f197e695ca68c488bce4289d2e79177ecb093a42 Mon Sep 17 00:00:00 2001 From: Jacob Hegna Date: Tue, 22 Apr 2014 19:38:27 -0500 Subject: [PATCH 1/2] Added examples for parse_bytes(buf: &[u8], radix: uint) in int_macros.rs and uint_macros.rs --- src/libstd/num/int_macros.rs | 10 ++++++++++ src/libstd/num/uint_macros.rs | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index a6b0ccf3a8725..0f8392839e507 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -235,6 +235,16 @@ impl Primitive for $T {} // String conversion functions and impl str -> num /// Parse a byte slice as a number in the given base. +/// +/// Yields an `Option` because `buf` may or may not actually be parseable. +/// +/// # Examples +/// +/// ```rust +/// let digits = [49,50,51,52,53,54,55,56,57]; +/// let base = 10; +/// let num = std::i64::from_str_radix(foo, 10); +/// ``` #[inline] pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> { strconv::from_str_bytes_common(buf, radix, true, false, false, diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index 9b9aee672a0f5..fe34ba830326f 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -149,6 +149,16 @@ impl Int for $T {} // String conversion functions and impl str -> num /// Parse a byte slice as a number in the given base. +/// +/// Yields an `Option` because `buf` may or may not actually be parseable. +/// +/// # Examples +/// +/// ```rust +/// let digits = [49,50,51,52,53,54,55,56,57]; +/// let base = 10; +/// let num = std::i64::parse_bytes(digits, base); +/// ``` #[inline] pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> { strconv::from_str_bytes_common(buf, radix, false, false, false, From a14c34d670fc76ccc025d5f7ae89ccbb811560c6 Mon Sep 17 00:00:00 2001 From: Jacob Hegna Date: Tue, 22 Apr 2014 19:47:57 -0500 Subject: [PATCH 2/2] Removed trailing whitespace in on line 242 in int_macros.rs and on line 156 in uint_macros.rs --- src/libstd/num/int_macros.rs | 4 ++-- src/libstd/num/uint_macros.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 0f8392839e507..cacd8d0aef91a 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -239,11 +239,11 @@ impl Primitive for $T {} /// Yields an `Option` because `buf` may or may not actually be parseable. /// /// # Examples -/// +/// /// ```rust /// let digits = [49,50,51,52,53,54,55,56,57]; /// let base = 10; -/// let num = std::i64::from_str_radix(foo, 10); +/// let num = std::i64::parse_bytes(digits, base); /// ``` #[inline] pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> { diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index fe34ba830326f..697390a00699c 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -153,7 +153,7 @@ impl Int for $T {} /// Yields an `Option` because `buf` may or may not actually be parseable. /// /// # Examples -/// +/// /// ```rust /// let digits = [49,50,51,52,53,54,55,56,57]; /// let base = 10;