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
63
64
65
66
mod basic_wrapper;
mod threaded_wrapper;
use std::fmt::Debug;
use std::ops::DerefMut;
use crate::IsBar;
pub use basic_wrapper::BarWrapper;
pub use threaded_wrapper::ThreadedBarWrapper;
#[allow(clippy::module_name_repetitions)]
#[cfg(not(feature = "nightly"))]
pub trait IsBarWrapper: crate::sealant::Sealed {
type Bar: IsBar;
type Error: Debug;
fn try_bar<'b>(&'b mut self)
-> Result<Box<dyn DerefMut<Target = Self::Bar> + 'b>, Self::Error>;
fn bar<'b>(&'b mut self) -> Box<dyn DerefMut<Target = Self::Bar> + 'b> {
self.try_bar().unwrap()
}
}
#[allow(clippy::module_name_repetitions)]
#[cfg(feature = "nightly")]
pub trait IsBarWrapper: crate::sealant::Sealed {
type Bar: IsBar;
type Error: Debug;
type BarGuard<'g>: DerefMut<Target = Self::Bar>
where
Self: 'g;
fn try_bar<'g>(&'g mut self) -> Result<Self::BarGuard<'g>, Self::Error>;
fn bar<'g>(&'g mut self) -> Self::BarGuard<'g> {
self.try_bar().unwrap()
}
}