diff --git a/src/libcore/char/convert.rs b/src/libcore/char/convert.rs index 803a924eb3a46..e9ccdd0ea3c57 100644 --- a/src/libcore/char/convert.rs +++ b/src/libcore/char/convert.rs @@ -115,6 +115,19 @@ pub unsafe fn from_u32_unchecked(i: u32) -> char { #[stable(feature = "char_convert", since = "1.13.0")] impl From for u32 { + /// Converts a [`char`] into a [`u32`]. + /// + /// # Examples + /// + /// ``` + /// use std::mem; + /// + /// fn main() { + /// let c = 'c'; + /// let u = u32::from(c); + /// assert!(4 == mem::size_of_val(&u)) + /// } + /// ``` #[inline] fn from(c: char) -> Self { c as u32 @@ -141,6 +154,19 @@ impl From for u32 { /// C0 and C1 control codes. #[stable(feature = "char_convert", since = "1.13.0")] impl From for char { + /// Converts a [`u8`] into a [`char`]. + /// + /// # Examples + /// + /// ``` + /// use std::mem; + /// + /// fn main() { + /// let u = 32 as u8; + /// let c = char::from(u); + /// assert!(4 == mem::size_of_val(&c)) + /// } + /// ``` #[inline] fn from(i: u8) -> Self { i as char