@@ -552,6 +552,12 @@ impl<C: 'static, C2: 'static, K2, T> ResultContext<K2, T>
552552
553553/// A trait for wrapping an existing UniResult with additional context.
554554pub trait UniResultContext < K , K2 , T > {
555+ /// Adds the provided context to the existing result error.
556+ fn add_context < F , S > ( self , context : F ) -> UniResult < T , K >
557+ where
558+ F : FnOnce ( ) -> S ,
559+ S : Into < Cow < ' static , str > > ;
560+
555561 /// Maps the existing result error wit the existing kind and returns a new or wrapped error.
556562 fn kind_map < F > ( self , f : F ) -> UniResult < T , K2 >
557563 where
@@ -577,6 +583,14 @@ pub trait UniResultContext<K, K2, T> {
577583}
578584
579585impl < K : UniKind , K2 , T > UniResultContext < K , K2 , T > for UniResult < T , K > {
586+ fn add_context < F , S > ( self , context : F ) -> UniResult < T , K >
587+ where
588+ F : FnOnce ( ) -> S ,
589+ S : Into < Cow < ' static , str > > ,
590+ {
591+ self . map_err ( |err| err. add_context ( context ( ) ) )
592+ }
593+
580594 fn kind_map < F > ( self , f : F ) -> UniResult < T , K2 >
581595 where
582596 F : FnOnce ( UniError < K > , K ) -> UniError < K2 > ,
0 commit comments