mirror of https://github.com/rust-lang/rust.git
Rollup merge of #97190 - SylvainDe:master, r=Dylan-DPC
Add implicit call to from_str via parse in documentation The documentation mentions "FromStr’s from_str method is often used implicitly, through str’s parse method. See parse’s documentation for examples.". It may be nicer to show that in the code example as well.
This commit is contained in:
commit
1210b50dbb
|
@ -530,8 +530,12 @@ unsafe impl const SliceIndex<str> for ops::RangeToInclusive<usize> {
|
|||
/// }
|
||||
/// }
|
||||
///
|
||||
/// let p = Point::from_str("(1,2)");
|
||||
/// assert_eq!(p.unwrap(), Point{ x: 1, y: 2} )
|
||||
/// let expected = Ok(Point { x: 1, y: 2 });
|
||||
/// // Explicit call
|
||||
/// assert_eq!(Point::from_str("(1,2)"), expected);
|
||||
/// // Implicit calls, through parse
|
||||
/// assert_eq!("(1,2)".parse(), expected);
|
||||
/// assert_eq!("(1,2)".parse::<Point>(), expected);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait FromStr: Sized {
|
||||
|
|
Loading…
Reference in New Issue