add trim() for Q3 of type-conversions

add `.map(|x| x.trim()) ` for Q3 of type-conversions
增加`"3, 4"`答案中有空格的情况
This commit is contained in:
Gengen Wang
2023-11-02 14:25:44 +08:00
committed by GitHub
parent f6e96bc9f9
commit 91724a5136

View File

@ -61,6 +61,7 @@ impl FromStr for Point {
fn from_str(s: &str) -> Result<Self, Self::Err> {
let coords: Vec<&str> = s.trim_matches(|p| p == '(' || p == ')' )
.split(',')
.map(|x| x.trim())
.collect();
let x_fromstr = coords[0].parse::<i32>()?;