exercism / exercism/rust

decimal: replace homebuilt try_from with FromStr impl

未关闭
#1,037 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Rust
星标
1.8k
派生
548
平均合并
13 小时 3 分钟
30 天内合并 PR
2

描述

https://github.com/exercism/rust/blob/9ad579f44024e459656d9646df9e8f0b33a3af13/exercises/decimal/example.rs#L30

It's more idiomatic and expressive to `impl FromStr for Decimal` instead of using a custom parse method. This is very slightly harder for the students, but it makes usage much nicer:

```diff
- let decimal = Decimal.try_from("123.45")?;
+ let decimal: Decimal = "123.45".parse()?;
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。