diff options
Diffstat (limited to 'src/libserialize/hex.rs')
| -rw-r--r-- | src/libserialize/hex.rs | 76 |
1 files changed, 36 insertions, 40 deletions
diff --git a/src/libserialize/hex.rs b/src/libserialize/hex.rs index 78859d6778d..2a3c410ba7c 100644 --- a/src/libserialize/hex.rs +++ b/src/libserialize/hex.rs @@ -27,21 +27,19 @@ pub trait ToHex for Sized? { static CHARS: &'static[u8] = b"0123456789abcdef"; impl ToHex for [u8] { - /** - * Turn a vector of `u8` bytes into a hexadecimal string. - * - * # Example - * - * ```rust - * extern crate serialize; - * use serialize::hex::ToHex; - * - * fn main () { - * let str = [52,32].to_hex(); - * println!("{}", str); - * } - * ``` - */ + /// Turn a vector of `u8` bytes into a hexadecimal string. + /// + /// # Example + /// + /// ```rust + /// extern crate serialize; + /// use serialize::hex::ToHex; + /// + /// fn main () { + /// let str = [52,32].to_hex(); + /// println!("{}", str); + /// } + /// ``` fn to_hex(&self) -> String { let mut v = Vec::with_capacity(self.len() * 2); for &byte in self.iter() { @@ -95,31 +93,29 @@ impl error::Error for FromHexError { impl FromHex for str { - /** - * Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) - * to the byte values it encodes. - * - * You can use the `String::from_utf8` function to turn a - * `Vec<u8>` into a string with characters corresponding to those values. - * - * # Example - * - * This converts a string literal to hexadecimal and back. - * - * ```rust - * extern crate serialize; - * use serialize::hex::{FromHex, ToHex}; - * - * fn main () { - * let hello_str = "Hello, World".as_bytes().to_hex(); - * println!("{}", hello_str); - * let bytes = hello_str.as_slice().from_hex().unwrap(); - * println!("{}", bytes); - * let result_str = String::from_utf8(bytes).unwrap(); - * println!("{}", result_str); - * } - * ``` - */ + /// Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) + /// to the byte values it encodes. + /// + /// You can use the `String::from_utf8` function to turn a + /// `Vec<u8>` into a string with characters corresponding to those values. + /// + /// # Example + /// + /// This converts a string literal to hexadecimal and back. + /// + /// ```rust + /// extern crate serialize; + /// use serialize::hex::{FromHex, ToHex}; + /// + /// fn main () { + /// let hello_str = "Hello, World".as_bytes().to_hex(); + /// println!("{}", hello_str); + /// let bytes = hello_str.as_slice().from_hex().unwrap(); + /// println!("{}", bytes); + /// let result_str = String::from_utf8(bytes).unwrap(); + /// println!("{}", result_str); + /// } + /// ``` fn from_hex(&self) -> Result<Vec<u8>, FromHexError> { // This may be an overestimate if there is any whitespace let mut b = Vec::with_capacity(self.len() / 2); |
