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// The pub module is a workaround for strange error:
21// "macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths"
22#[doc(hidden)]
23pub mod rust_version {
24    include!(concat!(env!("OUT_DIR"), "/rust_version.rs"));
25}
26
27#[doc(hidden)]
28pub mod _export {
29    #[cfg(feature = "alloc")]
30    pub extern crate alloc;
31}
32
33pub mod array;
34pub mod array_vec;
35pub mod error;
36pub mod script;
37pub mod slice;
38#[cfg(feature = "serde")]
39#[macro_use]
40pub mod serde;
41pub mod const_casts;
42pub mod u256;
43
44/// Asserts a boolean expression at compile time.
45#[macro_export]
46macro_rules! const_assert {
47    ($x:expr $(; $message:expr)?) => {
48        const _: () = {
49            if !$x {
50                // We can't use formatting in const, only concatenating literals.
51                panic!(concat!("assertion ", stringify!($x), " failed" $(, ": ", $message)?))
52            }
53        };
54    }
55}