musli_core/alloc/
mod.rs

1//! # Müsli Rust core allocation and collections library
2//!
3//! This library provides smart pointers and collections for managing allocated
4//! values. This is similar to the Rust [`alloc`][std-alloc] crate, it provides
5//! similar but more limited functionality. However it can do so safely using
6//! the Müsli-specific [`Allocator`] trait allowing these types to be used in
7//! `no_std` environments without requiring a nightly compiler or `unsafe`.
8//!
9//! [std-alloc]: rust_alloc
10
11mod to_owned;
12#[doc(inline)]
13pub use self::to_owned::ToOwned;
14
15mod allocator;
16#[doc(inline)]
17pub use self::allocator::{Allocator, GlobalAllocator};
18
19mod string;
20pub(crate) use self::string::collect_string;
21#[doc(inline)]
22pub use self::string::{FromUtf8Error, String};
23
24mod vec;
25#[doc(inline)]
26pub use self::vec::Vec;
27
28mod boxed;
29#[doc(inline)]
30pub use self::boxed::Box;
31
32#[allow(clippy::module_inception)]
33mod alloc;
34#[doc(inline)]
35pub use self::alloc::Alloc;
36
37use core::fmt;
38
39/// An allocation error.
40#[derive(Debug, PartialEq, Eq)]
41pub struct AllocError;
42
43impl fmt::Display for AllocError {
44    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
45        write!(f, "Failed to allocate memory")
46    }
47}
48
49impl core::error::Error for AllocError {}