File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -519,12 +519,14 @@ unsafe impl const SliceIndex<str> for ops::RangeToInclusive<usize> {
519519/// type Err = ParseIntError;
520520///
521521/// fn from_str(s: &str) -> Result<Self, Self::Err> {
522- /// let coords: Vec<&str> = s.trim_matches(|p| p == '(' || p == ')' )
523- /// .split(',')
524- /// .collect();
525- ///
526- /// let x_fromstr = coords[0].parse::<i32>()?;
527- /// let y_fromstr = coords[1].parse::<i32>()?;
522+ /// let (x, y) = s
523+ /// .strip_prefix('(')
524+ /// .and_then(|s| s.strip_suffix(')'))
525+ /// .and_then(|s| s.split_once(','))
526+ /// .unwrap();
527+ ///
528+ /// let x_fromstr = x.parse::<i32>()?;
529+ /// let y_fromstr = y.parse::<i32>()?;
528530///
529531/// Ok(Point { x: x_fromstr, y: y_fromstr })
530532/// }
You can’t perform that action at this time.
0 commit comments