toint 0.2.0

A simple Toint function for String
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

#[allow(dead_code)]
pub trait ToInt {
    fn to_int(&self) -> Result<i32, std::num::ParseIntError>;
}

impl ToInt for &str {
    fn to_int(&self) -> Result<i32, std::num::ParseIntError> {
        self.parse::<i32>()
    }
}

impl ToInt for String {
    fn to_int(&self) -> Result<i32, std::num::ParseIntError> {
        self.parse::<i32>()
    }
}