1#![no_std]
9#![cfg_attr(docsrs, feature(doc_auto_cfg))]
11#![warn(missing_docs)]
13#![doc(test(attr(warn(unused))))]
14#![allow(clippy::needless_question_mark)] #![allow(clippy::manual_range_contains)] #![allow(clippy::needless_borrows_for_generic_args)] #[cfg(feature = "alloc")]
20extern crate alloc;
21
22#[cfg(feature = "std")]
23extern crate std;
24
25#[cfg(feature = "test-serde")]
26pub extern crate serde_json;
27
28#[cfg(feature = "test-serde")]
29pub extern crate bincode;
30
31#[doc(hidden)]
34pub mod rust_version {
35 include!(concat!(env!("OUT_DIR"), "/rust_version.rs"));
36}
37
38pub mod array_vec;
39pub mod compact_size;
40pub mod const_tools;
41pub mod error;
42pub mod macros;
43mod parse;
44pub mod script;
45#[cfg(feature = "serde")]
46#[macro_use]
47pub mod serde;
48
49pub trait ToU64 {
54 fn to_u64(self) -> u64;
56}
57
58macro_rules! impl_to_u64 {
59 ($($ty:ident),*) => {
60 $(
61 impl ToU64 for $ty { fn to_u64(self) -> u64 { self.into() } }
62 )*
63 }
64}
65impl_to_u64!(u8, u16, u32, u64);
66
67impl ToU64 for usize {
68 fn to_u64(self) -> u64 {
69 crate::const_assert!(
70 core::mem::size_of::<usize>() <= 8;
71 "platforms that have usize larger than 64 bits are not supported"
72 );
73 self as u64
74 }
75}