1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use Debug;
/// Trait for [type constructors](https://en.wikipedia.org/wiki/Type_constructor) of
/// reference-counting pointers.
///
/// # Safety
///
/// `T` may be `!`[`Unpin`], and [`SharedPointer`][1] may be held in a pinned
/// form ([`Pin`][2]`<SharedPointer<T, Self>>`).
/// As such, the implementation of this trait must uphold the pinning invariants
/// for `T` while it's held in `Self`. Specifically, this necessitates the
/// following:
///
/// - `&mut T` is only exposed through the trait methods returning `&mut T`.
///
/// - The implementor must not move out the contained `T` unless the semantics
/// of trait methods demands that.
///
/// - [`Self::drop`] drops `T` in place.
///
/// [1]: crate::shared_pointer::SharedPointer
/// [2]: core::pin::Pin
//
// There are two conditions for types implementing this trait to be used in a safe way:
//
// 1. Always use the correct type `T`.
// 2. Make sure that you use it wrapped in something that derives the correct auto-traits taking
// into account the type of `T`.
//
// To elaborate on point 2: a `ArcK` will always implement `Send + Sync`, but that
// is only safe if the actually type that `ArcK` holds is in fact `Send + Sync`.
// This means that a safe wrapper around this type must make sure it does not implement
// `Send + Sync` unless `T: Send + Sync`. This is holds true for `SharedPointer` since it has a
// phantom field with `T`, thus the compiler will only make `SharedPointer<T>` implement
// `Send + Sync` if `T: Send + Sync`.
pub unsafe
use Box;
pub use ArcK;
pub use ArcTK;
pub use RcK;