rune_alloc/
lib.rs

1//! <img alt="rune logo" src="https://raw.githubusercontent.com/rune-rs/rune/main/assets/icon.png" />
2//! <br>
3//! <a href="https://github.com/rune-rs/rune"><img alt="github" src="https://img.shields.io/badge/github-rune--rs/rune-8da0cb?style=for-the-badge&logo=github" height="20"></a>
4//! <a href="https://crates.io/crates/rune-alloc"><img alt="crates.io" src="https://img.shields.io/crates/v/rune-alloc.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20"></a>
5//! <a href="https://docs.rs/rune-alloc"><img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rune--alloc-66c2a5?style=for-the-badge&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20"></a>
6//! <a href="https://discord.gg/v5AeNkT"><img alt="chat on discord" src="https://img.shields.io/discord/558644981137670144.svg?logo=discord&style=flat-square" height="20"></a>
7//! <br>
8//! Minimum support: Rust <b>1.92+</b>.
9//! <br>
10//! <br>
11//! <a href="https://rune-rs.github.io"><b>Visit the site 🌐</b></a>
12//! &mdash;
13//! <a href="https://rune-rs.github.io/book/"><b>Read the book 📖</b></a>
14//! <br>
15//! <br>
16//!
17//! The Rune Language, an embeddable dynamic programming language for Rust.
18// Quite a few parts copied from the Rust Project under the MIT license.
19//
20// Copyright 2014-2024 The Rust Project Developers
21//
22// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
23// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT
24// or https://opensource.org/licenses/MIT>, at your option. Files in the project
25// may not be copied, modified, or distributed except according to those terms.
26
27// hashbrown
28//
29// Copyright (c) 2016 Amanieu d'Antras
30//
31// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
32// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT
33// or https://opensource.org/licenses/MIT>, at your option. Files in the project
34// may not be copied, modified, or distributed except according to those terms.
35
36#![allow(clippy::comparison_chain)]
37#![allow(clippy::drop_non_drop)]
38#![allow(clippy::manual_map)]
39#![allow(clippy::type_complexity)]
40#![cfg_attr(rune_docsrs, feature(doc_cfg))]
41#![cfg_attr(rune_nightly, allow(internal_features))]
42#![cfg_attr(rune_nightly, feature(core_intrinsics))]
43#![cfg_attr(rune_nightly, feature(dropck_eyepatch))]
44#![cfg_attr(rune_nightly, feature(fmt_internals))]
45#![cfg_attr(rune_nightly, feature(min_specialization))]
46#![cfg_attr(rune_nightly, feature(rustc_attrs))]
47#![cfg_attr(rune_nightly, feature(slice_range))]
48#![deny(rustdoc::broken_intra_doc_links)]
49#![deny(rustdoc::private_doc_tests)]
50#![no_std]
51
52#[cfg(feature = "std")]
53extern crate std;
54
55#[cfg(feature = "alloc")]
56extern crate alloc as rust_alloc;
57
58// This is here for forward compatibility when we can support allocation-free
59// execution.
60#[cfg(not(feature = "alloc"))]
61compile_error!("The `alloc` feature is currently required to build rune-alloc, but will change for parts of rune in the future.");
62
63/// A `Result` aliased specialized towards an allocation [`Error`].
64pub type Result<T, E = crate::error::Error> = core::result::Result<T, E>;
65
66#[cfg(not(feature = "std"))]
67mod no_std;
68#[cfg(not(feature = "std"))]
69pub use self::no_std::abort;
70
71#[cfg(feature = "std")]
72pub use std::process::abort;
73
74#[cfg(feature = "serde")]
75mod serde;
76
77#[macro_use]
78mod public_macros;
79#[macro_use]
80mod macros;
81pub use self::error::Error;
82pub mod boxed;
83pub mod error;
84pub(crate) mod raw_vec;
85pub mod str;
86#[doc(inline)]
87pub use self::boxed::Box;
88pub(crate) mod btree;
89#[doc(inline)]
90pub use self::btree::{map as btree_map, map::BTreeMap};
91#[doc(inline)]
92pub use self::btree::{set as btree_set, set::BTreeSet};
93#[doc(hidden)]
94pub mod hashbrown;
95#[doc(inline)]
96pub use self::hashbrown::{map as hash_map, map::HashMap};
97#[doc(inline)]
98pub use self::hashbrown::{set as hash_set, set::HashSet};
99pub mod vec;
100#[doc(inline)]
101pub use self::vec::Vec;
102pub mod vec_deque;
103#[doc(inline)]
104pub use self::vec_deque::VecDeque;
105pub mod string;
106#[doc(inline)]
107pub use self::string::String;
108pub mod alloc;
109pub mod borrow;
110pub mod clone;
111pub mod fmt;
112pub(crate) mod hint;
113pub mod iter;
114mod option;
115pub(crate) mod ptr;
116pub mod sync;
117
118#[doc(hidden)]
119pub mod callable;
120#[doc(hidden)]
121pub mod slice;
122
123#[cfg(feature = "musli")]
124mod musli;
125
126pub mod limit;
127
128#[cfg(test)]
129mod testing;
130
131#[cfg(test)]
132mod tests;
133
134pub mod prelude {
135    //! Prelude for common traits used in combination with this crate which
136    //! matches the behavior of the std prelude.
137
138    pub use crate::borrow::TryToOwned;
139    pub use crate::boxed::Box;
140    pub use crate::clone::{TryClone, TryCopy};
141    pub use crate::iter::{IteratorExt, TryExtend, TryFromIterator, TryFromIteratorIn};
142    pub use crate::option::OptionExt;
143    pub use crate::string::{String, TryToString};
144    pub use crate::vec::Vec;
145    pub use crate::{try_format, try_vec};
146}