rust-amplify / amplify-num

Amplifying rust numerics: sub-byte integers, big ints, custom floats etc
Apache License 2.0
3 stars 1 forks source link

Implement FromStr for big-sized num types #6

Open dr-orlovsky opened 3 years ago

josediegorobles commented 3 years ago

Hi,

It can be something like this?

`impl ::core::str::FromStr for $name {

[inline]

        fn from_str(s: &str) -> Result<Self, Self::Err> {
            let splitted = s.split("0x");
            let inner_big_int: Vec<u64> = splitted.map(|x| format!("0x{}", x)).
                                                    map(|x| x.parse::<u64>().unwrap()).
                                                    collect();
            let inner_big_int_array = inner_big_int.try_into().unwrap();
            Ok(Self(inner_big_int_array))
        }
    }`
dr-orlovsky commented 3 years ago

Thank you for grabbing the issue! Commenting in the PR itself