exercism / exercism/rust

decimal: replace homebuilt try_from with FromStr impl

Open
#1,037 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
1.8k
Forks
548
Avg merge
13h 3m
Merged PRs (30d)
2

Description

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()?;
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.