elysees/lib.rs
1// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11//! Fork of [`triomphe`](https://github.com/Manishearth/triomphe/), which is a fork of [`Arc`][std::sync::Arc]. This has the following advantages over [`std::sync::Arc`]:
12//!
13//! * [`elysees::Arc`][`Arc`] doesn't support weak references: we save space by excluding the weak reference count, and we don't do extra read-modify-update operations to handle the possibility of weak references.
14//! * [`elysees::ArcBox`][`ArcBox`] allows one to construct a temporarily-mutable [`Arc`] which can be converted to a regular [`elysees::Arc`][`Arc`] later
15//! * [`elysees::ArcBorrow`][`ArcBorrow`] is functionally similar to [`&elysees::Arc<T>`][`Arc`], however in memory it's simply a (non-owned) pointer to the inner [`Arc`]. This helps avoid pointer-chasing.
16//! * [`elysees::ArcRef`][`ArcRef`] is a union of an [`Arc`] and an [`ArcBorrow`]
17
18#![allow(missing_docs)]
19#![cfg_attr(not(feature = "std"), no_std)]
20
21extern crate alloc;
22#[cfg(feature = "std")]
23extern crate core;
24
25#[cfg(feature = "arc-swap")]
26extern crate arc_swap;
27#[cfg(feature = "serde")]
28extern crate serde;
29#[cfg(feature = "stable_deref_trait")]
30extern crate stable_deref_trait;
31#[cfg(feature = "unsize")]
32extern crate unsize;
33
34mod arc;
35mod arc_borrow;
36mod arc_ref;
37#[cfg(feature = "arc-swap")]
38mod arc_swap_support;
39mod unique_arc;
40
41pub use arc::*;
42pub use arc_borrow::*;
43pub use arc_ref::*;
44pub use unique_arc::*;
45
46#[cfg(feature = "std")]
47use std::process::abort;
48
49// `no_std`-compatible abort by forcing a panic while already panicing.
50#[cfg(not(feature = "std"))]
51#[cold]
52fn abort() -> ! {
53 struct PanicOnDrop;
54 impl Drop for PanicOnDrop {
55 fn drop(&mut self) {
56 panic!()
57 }
58 }
59 let _double_panicer = PanicOnDrop;
60 panic!();
61}