mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-22 20:19:42 +00:00
Merge pull request #472 from XuGuangnian/patch-2
add trim for Q3 of type-conversions
This commit is contained in:
@ -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>()?;
|
||||
@ -165,4 +166,4 @@ fn main() {
|
||||
}
|
||||
```
|
||||
|
||||
> 你可以在[这里](https://github.com/sunface/rust-by-practice/blob/master/solutions/type-conversions/others.md)找到答案(在 solutions 路径下)
|
||||
> 你可以在[这里](https://github.com/sunface/rust-by-practice/blob/master/solutions/type-conversions/others.md)找到答案(在 solutions 路径下)
|
||||
|
Reference in New Issue
Block a user