File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -117,8 +117,17 @@ pub unsafe fn from_u32_unchecked(i: u32) -> char {
117117impl From < char > for u32 {
118118 /// Converts a [`char`] into a [`u32`].
119119 ///
120- /// [`char`]: primitive.char.html
121- /// [`u32`]: primitive.u32.html
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+ /// ```
122131 #[ inline]
123132 fn from ( c : char ) -> Self {
124133 c as u32
@@ -147,8 +156,17 @@ impl From<char> for u32 {
147156impl From < u8 > for char {
148157 /// Converts a [`u8`] into a [`char`].
149158 ///
150- /// [`u8`]: primitive.u8.html
151- /// [`char`]: primitive.char.html
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+ /// ```
152170 #[ inline]
153171 fn from ( i : u8 ) -> Self {
154172 i as char
You can’t perform that action at this time.
0 commit comments