File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 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> {
233233 /// [`usize`]: ../../std/primitive.usize.html
234234 ///
235235 /// ```
236- /// let num_as_str : Option<String> = Some("12 ".to_string());
236+ /// let text : Option<String> = Some("Hello, world! ".to_string());
237237 /// // 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);
241242 /// ```
242243 #[ inline]
243244 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments