1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use super::error::{self, Error};
use super::num::Number;
#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Result<T: Number> {
pub value: T,
pub error: Error,
}
#[inline(always)]
pub(crate) fn success<T>(value: T)
-> Result<T>
where T: Number
{
Result { value: value, error: error::success() }
}
#[inline(always)]
pub(crate) fn overflow_error<T>(value: T)
-> Result<T>
where T: Number
{
Result { value: value, error: error::overflow_error() }
}
#[inline(always)]
pub(crate) fn invalid_digit_error<T>(value: T, index: usize)
-> Result<T>
where T: Number
{
Result { value: value, error: error::invalid_digit_error(index) }
}
pub type U8Result = Result<u8>;
pub type U16Result = Result<u16>;
pub type U32Result = Result<u32>;
pub type U64Result = Result<u64>;
pub type U128Result = Result<u128>;
pub type UsizeResult = Result<usize>;
pub type I8Result = Result<i8>;
pub type I16Result = Result<i16>;
pub type I32Result = Result<i32>;
pub type I64Result = Result<i64>;
pub type I128Result = Result<i128>;
pub type IsizeResult = Result<isize>;
pub type F32Result = Result<f32>;
pub type F64Result = Result<f64>;