• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use minimal_lexical::bigint;
2 #[cfg(feature = "alloc")]
3 pub use minimal_lexical::heapvec::HeapVec as VecType;
4 #[cfg(not(feature = "alloc"))]
5 pub use minimal_lexical::stackvec::StackVec as VecType;
6 
vec_from_u32(x: &[u32]) -> VecType7 pub fn vec_from_u32(x: &[u32]) -> VecType {
8     let mut vec = VecType::new();
9     #[cfg(not(all(target_pointer_width = "64", not(target_arch = "sparc"))))]
10     {
11         for &xi in x {
12             vec.try_push(xi as bigint::Limb).unwrap();
13         }
14     }
15 
16     #[cfg(all(target_pointer_width = "64", not(target_arch = "sparc")))]
17     {
18         for xi in x.chunks(2) {
19             match xi.len() {
20                 1 => vec.try_push(xi[0] as bigint::Limb).unwrap(),
21                 2 => {
22                     let xi0 = xi[0] as bigint::Limb;
23                     let xi1 = xi[1] as bigint::Limb;
24                     vec.try_push((xi1 << 32) | xi0).unwrap()
25                 },
26                 _ => unreachable!(),
27             }
28         }
29     }
30 
31     vec
32 }
33