fastnum/bint/int/
convert.rs1mod from_float;
2mod from_int;
3mod from_uint;
4mod to_int;
5mod to_uint;
6
7use from_float::*;
8use from_int::*;
9use from_uint::*;
10use to_int::*;
11use to_uint::*;
12
13use bnum::BInt;
14use core::str::from_utf8_unchecked;
15
16#[cfg(not(feature = "std"))]
17use alloc::{string::String, vec::Vec};
18
19use crate::bint::{
20 convert, doc,
21 error::from_int_error_kind,
22 int::intrinsics::{self, *},
23 Int, ParseError, UInt,
24};
25
26impl<const N: usize> Int<N> {
27 convert::from_str::from_str_impl!(Int, I, BInt);
28
29 convert::from_bytes::from_bytes_impl!(Int, I, BInt);
30
31 from_uint_impl!(
32 from_u8 <- u8,
33 from_u16 <- u16,
34 from_u32 <- u32
35 );
36
37 try_from_uint_impl!(
38 from_u64 <- u64,
39 from_usize <- usize,
40 from_u128 <- u128 #TRY
41 );
42
43 from_int_impl!(
44 from_i8 <- i8,
45 from_i16 <- i16,
46 from_i32 <- i32,
47 from_i64 <- i64,
48 from_isize <- isize
49 );
50
51 try_from_int_impl!(
52 from_i128 <- i128
53 );
54
55 from_float_impl!(from_f32, f32);
56 from_float_impl!(from_f64, f64);
57}
58
59impl<const N: usize> Int<N> {
60 convert::to_str::to_str_impl!(Int, I, BInt);
61
62 convert::to_bytes::to_bytes_impl!(Int, I, BInt);
63
64 to_int_impl!(
65 to_i8 -> i8,
66 to_i16 -> i16,
67 to_i32 -> i32,
68 to_i64 -> i64,
69 to_i128 -> i128,
70 to_isize -> isize
71 );
72
73 to_uint_impl!(
74 to_u8 -> u8,
75 to_u16 -> u16,
76 to_u32 -> u32,
77 to_u64 -> u64,
78 to_u128 -> u128,
79 to_usize -> usize
80 );
81}