diff --git a/core/src/str/traits.rs b/core/src/str/traits.rs index 32c31803a..e9649fc91 100644 --- a/core/src/str/traits.rs +++ b/core/src/str/traits.rs @@ -519,12 +519,14 @@ unsafe impl const SliceIndex for ops::RangeToInclusive { /// type Err = ParseIntError; /// /// fn from_str(s: &str) -> Result { -/// let coords: Vec<&str> = s.trim_matches(|p| p == '(' || p == ')' ) -/// .split(',') -/// .collect(); -/// -/// let x_fromstr = coords[0].parse::()?; -/// let y_fromstr = coords[1].parse::()?; +/// let (x, y) = s +/// .strip_prefix('(') +/// .and_then(|s| s.strip_suffix(')')) +/// .and_then(|s| s.split_once(',')) +/// .unwrap(); +/// +/// let x_fromstr = x.parse::()?; +/// let y_fromstr = y.parse::()?; /// /// Ok(Point { x: x_fromstr, y: y_fromstr }) /// }