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
//! Collection of utilities to be used in [Mapper](crate::Mapper) `with` and `try_with` arguments

#[cfg(feature = "chrono")]
mod chrono;
#[cfg(feature = "chrono")]
pub use chrono::*;

mod hashmap;
mod option;
mod vec;
pub use hashmap::*;
pub use option::*;
pub use vec::*;

/// Mapper for types implementing [ExtraInto]
pub fn extra<F, I>(from: F) -> I
where
    F: ExtraInto<I>,
{
    ExtraInto::into_extra(from)
}

/// Owned trait to implement [Into] on foreign types
pub trait ExtraInto<I> {
    fn into_extra(self) -> I;
}

/// Owned trait to implement [TryInto] on foreign types
pub trait TryExtraInto<I> {
    type Error;
    fn try_into_extra(self) -> Result<I, Self::Error>;
}