File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 1
1
Unreleased
2
2
==========
3
3
* Implement the ` std::ops::AddAssign ` trait for ` AsciiString ` .
4
+ * Implement the ` IntoAsciiString ` for ` std::borrow::Cow ` , where the inner types themselves
5
+ implement ` IntoAsciiString ` .
4
6
5
7
Version 0.9.1 (2018-09-12)
6
8
==========================
Original file line number Diff line number Diff line change @@ -784,6 +784,41 @@ impl<'a> IntoAsciiString for &'a str {
784
784
}
785
785
}
786
786
787
+ impl < ' a , B : ?Sized > IntoAsciiString for Cow < ' a , B >
788
+ where
789
+ B : ' a + ToOwned ,
790
+ & ' a B : IntoAsciiString ,
791
+ <B as ToOwned >:: Owned : IntoAsciiString ,
792
+ {
793
+ #[ inline]
794
+ unsafe fn into_ascii_string_unchecked ( self ) -> AsciiString {
795
+ IntoAsciiString :: into_ascii_string_unchecked ( self . into_owned ( ) )
796
+ }
797
+
798
+ fn into_ascii_string ( self ) -> Result < AsciiString , FromAsciiError < Self > > {
799
+ match self {
800
+ Cow :: Owned ( b) => {
801
+ IntoAsciiString :: into_ascii_string ( b)
802
+ . map_err ( |FromAsciiError { error, owner } | {
803
+ FromAsciiError {
804
+ owner : Cow :: Owned ( owner) ,
805
+ error : error,
806
+ }
807
+ } )
808
+ }
809
+ Cow :: Borrowed ( b) => {
810
+ IntoAsciiString :: into_ascii_string ( b)
811
+ . map_err ( |FromAsciiError { error, owner } | {
812
+ FromAsciiError {
813
+ owner : Cow :: Borrowed ( owner) ,
814
+ error : error,
815
+ }
816
+ } )
817
+ }
818
+ }
819
+ }
820
+ }
821
+
787
822
#[ cfg( feature = "quickcheck" ) ]
788
823
impl Arbitrary for AsciiString {
789
824
fn arbitrary < G : Gen > ( g : & mut G ) -> Self {
You can’t perform that action at this time.
0 commit comments