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.87+</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#![no_std]
37#![deny(rustdoc::broken_intra_doc_links)]
38#![deny(rustdoc::private_doc_tests)]
39#![cfg_attr(rune_nightly, allow(internal_features))]
40#![cfg_attr(rune_nightly, feature(fmt_internals))]
41#![cfg_attr(rune_nightly, feature(core_intrinsics))]
42#![cfg_attr(rune_nightly, feature(dropck_eyepatch))]
43#![cfg_attr(rune_nightly, feature(min_specialization))]
44#![cfg_attr(rune_nightly, feature(slice_range))]
45#![cfg_attr(rune_nightly, feature(rustc_attrs))]
46#![allow(clippy::comparison_chain)]
47#![allow(clippy::manual_map)]
48#![allow(clippy::type_complexity)]
49#![allow(clippy::drop_non_drop)]
50
51#[cfg(feature = "std")]
52extern crate std;
53
54#[cfg(feature = "alloc")]
55extern crate alloc as rust_alloc;
56
57// This is here for forward compatibility when we can support allocation-free
58// execution.
59#[cfg(not(feature = "alloc"))]
60compile_error!("The `alloc` feature is currently required to build rune-alloc, but will change for parts of rune in the future.");
61
62/// A `Result` aliased specialized towards an allocation [`Error`].
63pub type Result<T, E = crate::error::Error> = core::result::Result<T, E>;
64
65#[cfg(feature = "std")]
66pub use std::path;
67#[cfg(not(feature = "std"))]
68pub mod path;
69
70#[cfg(not(feature = "std"))]
71mod no_std;
72#[cfg(not(feature = "std"))]
73pub use self::no_std::abort;
74
75#[cfg(feature = "std")]
76pub use std::process::abort;
77
78#[cfg(feature = "serde")]
79mod serde;
80
81#[macro_use]
82mod public_macros;
83#[macro_use]
84mod macros;
85pub use self::error::Error;
86pub mod boxed;
87pub mod error;
88pub(crate) mod raw_vec;
89pub mod str;
90#[doc(inline)]
91pub use self::boxed::Box;
92pub(crate) mod btree;
93#[doc(inline)]
94pub use self::btree::{map as btree_map, map::BTreeMap};
95#[doc(inline)]
96pub use self::btree::{set as btree_set, set::BTreeSet};
97#[doc(hidden)]
98pub mod hashbrown;
99#[doc(inline)]
100pub use self::hashbrown::{map as hash_map, map::HashMap};
101#[doc(inline)]
102pub use self::hashbrown::{set as hash_set, set::HashSet};
103pub mod vec;
104#[doc(inline)]
105pub use self::vec::Vec;
106pub mod vec_deque;
107#[doc(inline)]
108pub use self::vec_deque::VecDeque;
109pub mod string;
110#[doc(inline)]
111pub use self::string::String;
112pub mod alloc;
113pub mod borrow;
114pub mod clone;
115pub mod fmt;
116pub(crate) mod hint;
117pub mod iter;
118mod option;
119pub(crate) mod ptr;
120pub mod sync;
121
122#[doc(hidden)]
123pub mod callable;
124#[doc(hidden)]
125pub mod slice;
126
127#[cfg(feature = "musli")]
128mod musli;
129
130pub mod limit;
131
132#[cfg(test)]
133mod testing;
134
135#[cfg(test)]
136mod tests;
137
138pub mod prelude {
139    //! Prelude for common traits used in combination with this crate which
140    //! matches the behavior of the std prelude.
141
142    pub use crate::borrow::TryToOwned;
143    pub use crate::boxed::Box;
144    pub use crate::clone::{TryClone, TryCopy};
145    pub use crate::iter::{IteratorExt, TryExtend, TryFromIterator, TryFromIteratorIn};
146    pub use crate::option::OptionExt;
147    pub use crate::string::{String, TryToString};
148    pub use crate::vec::Vec;
149    pub use crate::{try_format, try_vec};
150}