rune/
alloc.rs

1//! # The Rune core allocation and collections library
2//!
3//! This library provides smart pointers and collections for managing
4//! heap-allocated values.
5//!
6//! It is a fork of the [`alloc`] and [`hashbrown`] crates with the following
7//! additions:
8//! * All allocations are fallible, and subject to memory limits imposed by the
9//!   [`limit`] module.
10//! * All colllections can be used by dynamic types, which can fallibly
11//!   implement the trait they need. Such as [`Hash`] and [`Eq`] for [`HashMap`]
12//!   or [`Ord`] for [`BTreeMap`]. This is accomplished using alternative
13//!   functions which receive fallible closures and contexts, such as
14//!   [`BTreeMap::get_mut_with`].
15//!
16//! [`alloc`]: https://doc.rust-lang.org/stable/alloc/
17//! [`hashbrown`]: https://docs.rs/hashbrown
18//!
19//! ## Boxed values
20//!
21//! The [`Box`] type is a smart pointer type. There can only be one owner of a
22//! [`Box`], and the owner can decide to mutate the contents, which live on the
23//! heap.
24//!
25//! This type can be sent among threads efficiently as the size of a `Box` value
26//! is the same as that of a pointer. Tree-like data structures are often built
27//! with boxes because each node often has only one owner, the parent.
28//!
29//! ## Collections
30//!
31//! Implementations of the most common general purpose data structures are
32//! defined in this library. They are re-exported through the
33//! [standard collections library](../std/collections/index.html).
34//!
35//! ## Heap interfaces
36//!
37//! The [`alloc`] module defines the low-level interface to the default global
38//! allocator. It is not compatible with the libc allocator API.
39//!
40//! [`Box`]: boxed
41//! [`Cell`]: core::cell
42//! [`RefCell`]: core::cell
43
44#[doc(inline)]
45pub use rune_alloc::abort;
46#[doc(inline)]
47pub use rune_alloc::alloc;
48#[doc(inline)]
49pub use rune_alloc::borrow;
50#[doc(inline)]
51pub use rune_alloc::clone;
52#[doc(inline)]
53pub use rune_alloc::fmt;
54#[doc(inline)]
55pub use rune_alloc::iter;
56#[doc(inline)]
57pub use rune_alloc::limit;
58#[doc(inline)]
59pub use rune_alloc::path;
60#[doc(inline)]
61pub use rune_alloc::str;
62#[doc(inline)]
63pub use rune_alloc::sync;
64#[doc(inline)]
65pub use rune_alloc::{boxed, Box};
66#[doc(inline)]
67pub use rune_alloc::{btree_map, BTreeMap};
68#[doc(inline)]
69pub use rune_alloc::{btree_set, BTreeSet};
70#[doc(inline)]
71pub use rune_alloc::{error, Error, Result};
72#[doc(inline)]
73pub use rune_alloc::{hash_map, HashMap};
74#[doc(inline)]
75pub use rune_alloc::{hash_set, HashSet};
76#[doc(inline)]
77pub use rune_alloc::{string, String};
78#[doc(inline)]
79pub use rune_alloc::{try_format, try_vec};
80#[doc(inline)]
81pub use rune_alloc::{vec, Vec};
82#[doc(inline)]
83pub use rune_alloc::{vec_deque, VecDeque};
84
85pub mod prelude {
86    //! Prelude for common traits used in combination with this crate which
87    //! matches the behavior of the std prelude.
88
89    #[doc(inline)]
90    pub use rune_alloc::prelude::*;
91}