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
use core::any::Any;
use core::fmt::{Debug, Display};
pub trait StringLike: Into<String> + AsRef<str> {
fn clone_string(&self) -> String {
self.as_ref().to_string()
}
}
impl<T> StringLike for T where T: Into<String> + AsRef<str> {}
pub trait Access<'a, Source> {
type Target: 'a;
fn access<'b>(&self, src: &'b Source) -> Self::Target
where
'b: 'a;
}
pub trait AccessMut<'a, Source> {
type Target: 'a;
fn access_mut<'b>(&self, src: &'b mut Source) -> Self::Target
where
'b: 'a;
}
pub trait AnyDebugDisplay: Any + Debug + Display {
fn as_any(&self) -> &dyn Any;
fn as_debug(&self) -> &dyn Debug;
fn as_display(&self) -> &dyn Display;
fn into_boxed_any(self: Box<Self>) -> Box<dyn Any>;
}
impl<T> AnyDebugDisplay for T
where
T: Any + Debug + Display,
{
fn as_any(&self) -> &dyn Any {
self
}
fn as_debug(&self) -> &dyn Debug {
self
}
fn as_display(&self) -> &dyn Display {
self
}
fn into_boxed_any(self: Box<Self>) -> Box<dyn Any> {
self
}
}