File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ impl<'de: 'a, 'a> Deserialize<'de> for Compatible<'a> {
3333 where
3434 E : serde:: de:: Error ,
3535 {
36- // TODO utf -8 check
36+ // no UTF -8 checks
3737 Ok ( Compatible { data : v } )
3838 }
3939 }
@@ -43,7 +43,14 @@ impl<'de: 'a, 'a> Deserialize<'de> for Compatible<'a> {
4343
4444impl fmt:: Debug for Compatible < ' _ > {
4545 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
46- f. debug_list ( ) . entries ( self . iter ( ) ) . finish ( )
46+ let mut list = f. debug_list ( ) ;
47+ for slice in self . iter ( ) {
48+ match core:: str:: from_utf8 ( slice) {
49+ Ok ( string) => list. entry ( & string) ,
50+ Err ( _error) => list. entry ( & slice) ,
51+ } ;
52+ }
53+ list. finish ( )
4754 }
4855}
4956
@@ -52,7 +59,7 @@ pub struct Iter<'a> {
5259}
5360
5461impl < ' a > Iterator for Iter < ' a > {
55- type Item = & ' a str ;
62+ type Item = & ' a [ u8 ] ;
5663
5764 fn next ( & mut self ) -> Option < Self :: Item > {
5865 if self . remaining . len ( ) == 0 {
@@ -70,6 +77,6 @@ impl<'a> Iterator for Iter<'a> {
7077 // skip '\0'
7178 self . remaining = & rest[ 1 ..] ;
7279 }
73- Some ( core :: str :: from_utf8 ( ans) . unwrap ( ) )
80+ Some ( ans)
7481 }
7582}
You can’t perform that action at this time.
0 commit comments