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