mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 02:00:00 +03:00
Added examples for parse_bytes(buf: &[u8], radix: uint) in int_macros.rs and uint_macros.rs
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user