Skip to main content

bitcoin_internals/
lib.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//! Rust Bitcoin Internal
4//!
5//! This crate is only meant to be used internally by crates in the
6//! [rust-bitcoin](https://github.com/rust-bitcoin) ecosystem.
7
8#![no_std]
9// Coding conventions.
10#![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// The pub module is a workaround for strange error:
27// "macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths"
28#[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 error;
42pub mod script;
43pub mod slice;
44#[cfg(feature = "serde")]
45#[macro_use]
46pub mod serde;
47pub mod const_casts;
48
49/// Asserts a boolean expression at compile time.
50#[macro_export]
51macro_rules! const_assert {
52    ($x:expr $(; $message:expr)?) => {
53        const _: () = {
54            if !$x {
55                // We can't use formatting in const, only concatenating literals.
56                panic!(concat!("assertion ", stringify!($x), " failed" $(, ": ", $message)?))
57            }
58        };
59    }
60}