scsys_core/traits/
wrapper.rs

1/*
2    Appellation: wrapper <module>
3    Contrib: @FL03
4*/
5
6/// [IntoInner] is typically used for basic structures that wrap a single value.
7pub trait IntoInner {
8    type Inner;
9
10    fn into_inner(self) -> Self::Inner;
11}
12
13/// Interface for nameable data-structures
14pub trait Name {
15    fn name(&self) -> &str;
16}
17
18pub trait Wrapper {
19    type Inner;
20
21    fn into_inner(self) -> Self::Inner;
22
23    fn as_inner(&self) -> &Self::Inner;
24
25    fn as_inner_mut(&mut self) -> &mut Self::Inner;
26}
27
28pub trait Mapper {
29    type Item;
30    type Cont<T>: Mapper<Item = T>;
31
32    fn map<U, F>(self, f: F) -> Self::Cont<U>
33    where
34        F: FnOnce(Self::Item) -> U;
35}