add "3, 4" answers with Spaces for Q3 of type-conversions/others

add `.map(|x| x.trim())`  for Q3 of type-conversions/others
Added "3, 4" answers with Spaces
This commit is contained in:
Gengen Wang
2023-11-13 16:39:18 +08:00
committed by GitHub
parent 819d9d414a
commit 2309fac720

View File

@ -60,6 +60,7 @@ impl FromStr for Point {
fn from_str(s: &str) -> Result<Self, Self::Err> { fn from_str(s: &str) -> Result<Self, Self::Err> {
let coords: Vec<&str> = s.trim_matches(|p| p == '(' || p == ')' ) let coords: Vec<&str> = s.trim_matches(|p| p == '(' || p == ')' )
.split(',') .split(',')
.map(|x| x.trim())
.collect(); .collect();
let x_fromstr = coords[0].parse::<i32>()?; let x_fromstr = coords[0].parse::<i32>()?;
@ -164,4 +165,4 @@ fn main() {
} }
``` ```
> You can find the solutions [here](https://github.com/sunface/rust-by-practice/blob/master/solutions/type-conversions/others.md)(under the solutions path), but only use it when you need it > You can find the solutions [here](https://github.com/sunface/rust-by-practice/blob/master/solutions/type-conversions/others.md)(under the solutions path), but only use it when you need it