String to Num

Parse a string to integer or float.

Unlike from_str_radix where user must provide a radix, this method support auto hex, dec, oct, bin detection

This trait is default implemented for str, so both str and String type can use this method.

Returns FromStrRadixErr on parse fail.

Examples

```rust use stringtonum::ParseNum;

asserteq!("0".parsenum::().unwrap(), 0i32); asserteq!("10".parsenum::().unwrap(), 10f32);

asserteq!("0x01".parsenum::().unwrap(), 1u16); asserteq!("0xFF".parsenum::().unwrap(), 255f64); asserteq!("0b1111".parsenum::().unwrap(), 0b1111u8); asserteq!("0o1463".parsenum::().unwrap(), 0o1463u16);

asserteq!("0XfF".tostring().parsenum::().unwrap(), 255f64); asserteq!("0B1111".tostring().parsenum::().unwrap(), 0b1111u8); asserteq!("0O1463".tostring().parse_num::().unwrap(), 0o1463u16); ```

License

This project is dual-licensed under MIT and Apache 2.0