File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -183,10 +183,15 @@ use boxed::Box;
183
183
/// }
184
184
/// ```
185
185
///
186
- /// What would work in this case is changing the line
187
- /// `example_func(&example_string);` to
188
- /// `example_func(example_string.to_str());`. This works because we're doing
189
- /// the conversion explicitly, rather than relying on the implicit conversion.
186
+ /// There are two options that would work instead. The first would be to
187
+ /// change the line `example_func(&example_string);` to
188
+ /// `example_func(example_string.as_str());`, using the method `as_str()`
189
+ /// to explicitly extract the string slice containing the string. The second
190
+ /// way changes `example_func(&example_string);` to
191
+ /// `example_func(&*example_string);`. In this case we are dereferencing a
192
+ /// `String` to a `str`, then referencing the `str` back to `&str`. The
193
+ /// second way is more idiomatic, however both work to do the conversion
194
+ /// explicitly rather than relying on the implicit conversion.
190
195
///
191
196
/// # Representation
192
197
///
You can’t perform that action at this time.
0 commit comments