File tree 1 file changed +5
-4
lines changed
1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -233,11 +233,12 @@ impl<T> Option<T> {
233
233
/// [`usize`]: ../../std/primitive.usize.html
234
234
///
235
235
/// ```
236
- /// let num_as_str : Option<String> = Some("12 ".to_string());
236
+ /// let text : Option<String> = Some("Hello, world! ".to_string());
237
237
/// // First, cast `Option<String>` to `Option<&String>` with `as_ref`,
238
- /// // then consume *that* with `map`, leaving `num_as_str` on the stack.
239
- /// let num_length: Option<usize> = num_as_str.as_ref().map(|n| n.len());
240
- /// println!("still can print num_as_str: {:?}", num_as_str);
238
+ /// // then consume *that* with `map`, leaving `text` on the stack.
239
+ /// let text_length: Option<usize> = text.as_ref().map(|s| s.len());
240
+ /// println!("text length: {}", text_length);
241
+ /// println!("still can print text: {:?}", text);
241
242
/// ```
242
243
#[ inline]
243
244
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments