File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,19 @@ pub unsafe fn from_u32_unchecked(i: u32) -> char {
115115
116116#[ stable( feature = "char_convert" , since = "1.13.0" ) ]
117117impl From < char > for u32 {
118+ /// Converts a [`char`] into a [`u32`].
119+ ///
120+ /// # Examples
121+ ///
122+ /// ```
123+ /// use std::mem;
124+ ///
125+ /// fn main() {
126+ /// let c = 'c';
127+ /// let u = u32::from(c);
128+ /// assert!(4 == mem::size_of_val(&u))
129+ /// }
130+ /// ```
118131 #[ inline]
119132 fn from ( c : char ) -> Self {
120133 c as u32
@@ -141,6 +154,19 @@ impl From<char> for u32 {
141154/// C0 and C1 control codes.
142155#[ stable( feature = "char_convert" , since = "1.13.0" ) ]
143156impl From < u8 > for char {
157+ /// Converts a [`u8`] into a [`char`].
158+ ///
159+ /// # Examples
160+ ///
161+ /// ```
162+ /// use std::mem;
163+ ///
164+ /// fn main() {
165+ /// let u = 32 as u8;
166+ /// let c = char::from(u);
167+ /// assert!(4 == mem::size_of_val(&c))
168+ /// }
169+ /// ```
144170 #[ inline]
145171 fn from ( i : u8 ) -> Self {
146172 i as char
You can’t perform that action at this time.
0 commit comments