//TODO potentially move HeaderTryFrom to `mail-headers` use error::ComponentCreationError; //TODO replace with std TryFrom once it is stable // (either a hard replace, or a soft replace which implements HeaderTryFrom if TryFrom exist) /// Workaround for `TryFrom`,`TryInto` not being stable. pub trait HeaderTryFrom: Sized { fn try_from(val: T) -> Result; } /// Workaround for `TryFrom`,`TryInto` not being stable. pub trait HeaderTryInto: Sized { fn try_into(self) -> Result; } impl HeaderTryInto for F where T: HeaderTryFrom { fn try_into(self) -> Result { T::try_from(self) } } impl HeaderTryFrom for T { fn try_from(val: T) -> Result { Ok( val ) } } // It is not possible to auto-implement HeaderTryFrom for From/Into as // this will make new HeaderTryFrom implementations outside of this care // nearly impossible making the trait partially useless // //impl HeaderTryFrom for T where F: Into { // fn try_from(val: F) -> Result { // Ok( val.into() ) // } //}