Skip to content

decimal: replace homebuilt try_from with FromStr impl #1037

Open
@coriolinus

Description

@coriolinus

pub fn try_from(mut input: &str) -> Option<Decimal> {

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:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions