1#![no_std]
9#![warn(missing_docs)]
11#![warn(deprecated_in_future)]
12#![doc(test(attr(warn(unused))))]
13
14#[cfg(feature = "alloc")]
15extern crate alloc;
16
17#[cfg(feature = "std")]
18extern crate std;
19
20#[cfg(feature = "test-serde")]
21pub extern crate serde_json;
22
23#[cfg(feature = "test-serde")]
24pub extern crate bincode;
25
26#[doc(hidden)]
29pub mod rust_version {
30 include!(concat!(env!("OUT_DIR"), "/rust_version.rs"));
31}
32
33#[doc(hidden)]
34pub mod _export {
35 #[cfg(feature = "alloc")]
36 pub extern crate alloc;
37}
38
39pub mod array;
40pub mod array_vec;
41pub mod compact_size;
42pub mod const_tools;
43pub mod error;
44pub mod macros;
45mod parse;
46pub mod script;
47pub mod slice;
48pub mod wrap_debug;
49#[cfg(feature = "serde")]
50#[macro_use]
51pub mod serde;
52pub mod const_casts;
53
54pub trait ToU64 {
59 fn to_u64(self) -> u64;
61}
62
63macro_rules! impl_to_u64 {
64 ($($ty:ident),*) => {
65 $(
66 impl ToU64 for $ty { fn to_u64(self) -> u64 { self.into() } }
67 )*
68 }
69}
70impl_to_u64!(u8, u16, u32, u64);
71
72impl ToU64 for usize {
73 fn to_u64(self) -> u64 {
74 crate::const_assert!(
75 core::mem::size_of::<usize>() <= 8;
76 "platforms that have usize larger than 64 bits are not supported"
77 );
78 self as u64
79 }
80}