From 91724a5136a9e30c335d8fc9e131c7cf66d11dcd Mon Sep 17 00:00:00 2001 From: Gengen Wang <35788677+XuGuangnian@users.noreply.github.com> Date: Thu, 2 Nov 2023 14:25:44 +0800 Subject: [PATCH] add trim() for Q3 of type-conversions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add `.map(|x| x.trim()) ` for Q3 of type-conversions 增加`"3, 4"`答案中有空格的情况 --- zh-CN/src/type-conversions/others.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zh-CN/src/type-conversions/others.md b/zh-CN/src/type-conversions/others.md index 9503340..35b55ef 100644 --- a/zh-CN/src/type-conversions/others.md +++ b/zh-CN/src/type-conversions/others.md @@ -61,6 +61,7 @@ impl FromStr for Point { fn from_str(s: &str) -> Result { let coords: Vec<&str> = s.trim_matches(|p| p == '(' || p == ')' ) .split(',') + .map(|x| x.trim()) .collect(); let x_fromstr = coords[0].parse::()?; @@ -165,4 +166,4 @@ fn main() { } ``` -> 你可以在[这里](https://github.com/sunface/rust-by-practice/blob/master/solutions/type-conversions/others.md)找到答案(在 solutions 路径下) \ No newline at end of file +> 你可以在[这里](https://github.com/sunface/rust-by-practice/blob/master/solutions/type-conversions/others.md)找到答案(在 solutions 路径下)