1 // The doc tests allow us to do a compile_fail test, which is cool and what we want, but we don't
2 // want to expose this in the docs, so we use a private struct for that reason.
3 //
4 // Note we also bundle one that *does* compile with each, just to make sure they don't silently
5 // not-compile by some different reason.
6 //! ```rust,compile_fail
7 //! let shared = arc_swap::ArcSwap::from_pointee(std::cell::Cell::new(42));
8 //! std::thread::spawn(|| {
9 //!     drop(shared);
10 //! });
11 //! ```
12 //!
13 //! ```rust
14 //! let shared = arc_swap::ArcSwap::from_pointee(42);
15 //! std::thread::spawn(|| {
16 //!     drop(shared);
17 //! })
18 //! .join()
19 //! .unwrap();
20 //! ```
21 //!
22 //! ```rust,compile_fail
23 //! let shared = arc_swap::ArcSwap::from_pointee(std::cell::Cell::new(42));
24 //! let guard = shared.load();
25 //! std::thread::spawn(|| {
26 //!     drop(guard);
27 //! });
28 //! ```
29 //!
30 //! ```rust
31 //! let shared = arc_swap::ArcSwap::from_pointee(42);
32 //! let guard = shared.load();
33 //! std::thread::spawn(|| {
34 //!     drop(guard);
35 //! })
36 //! .join()
37 //! .unwrap();
38 //! ```
39 //!
40 //! ```rust,compile_fail
41 //! let shared = arc_swap::ArcSwap::from_pointee(std::cell::Cell::new(42));
42 //! crossbeam_utils::thread::scope(|scope| {
43 //!     scope.spawn(|_| {
44 //!         let _ = &shared;
45 //!     });
46 //! }).unwrap();
47 //! ```
48 //!
49 //! ```rust
50 //! let shared = arc_swap::ArcSwap::from_pointee(42);
51 //! crossbeam_utils::thread::scope(|scope| {
52 //!     scope.spawn(|_| {
53 //!         let _ = &shared;
54 //!     });
55 //! }).unwrap();
56 //! ```
57 //!
58 //! ```rust,compile_fail
59 //! let shared = arc_swap::ArcSwap::from_pointee(std::cell::Cell::new(42));
60 //! let guard = shared.load();
61 //! crossbeam_utils::thread::scope(|scope| {
62 //!     scope.spawn(|_| {
63 //!         let _ = &guard;
64 //!     });
65 //! }).unwrap();
66 //! ```
67 //!
68 //! ```rust
69 //! let shared = arc_swap::ArcSwap::from_pointee(42);
70 //! let guard = shared.load();
71 //! crossbeam_utils::thread::scope(|scope| {
72 //!     scope.spawn(|_| {
73 //!         let _ = &guard;
74 //!     });
75 //! }).unwrap();
76 //! ```
77 //!
78 //! See that ArcSwapAny<Rc> really isn't Send.
79 //! ```rust
80 //! use std::sync::Arc;
81 //! use arc_swap::ArcSwapAny;
82 //!
83 //! let a: ArcSwapAny<Arc<usize>> = ArcSwapAny::new(Arc::new(42));
84 //! std::thread::spawn(move || drop(a)).join().unwrap();
85 //! ```
86 //!
87 //! ```rust,compile_fail
88 //! use std::rc::Rc;
89 //! use arc_swap::ArcSwapAny;
90 //!
91 //! let a: ArcSwapAny<Rc<usize>> = ArcSwapAny::new(Rc::new(42));
92 //! std::thread::spawn(move || drop(a));
93 //! ```
94