File tree 1 file changed +22
-4
lines changed
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 {
117
117
impl From < char > for u32 {
118
118
/// Converts a [`char`] into a [`u32`].
119
119
///
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
+ /// ```
122
131
#[ inline]
123
132
fn from ( c : char ) -> Self {
124
133
c as u32
@@ -147,8 +156,17 @@ impl From<char> for u32 {
147
156
impl From < u8 > for char {
148
157
/// Converts a [`u8`] into a [`char`].
149
158
///
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
+ /// ```
152
170
#[ inline]
153
171
fn from ( i : u8 ) -> Self {
154
172
i as char
You can’t perform that action at this time.
0 commit comments