@@ -514,16 +514,16 @@ where
514514 match self . write . back ( ) {
515515 // Skip all subtree, if we skip a start event
516516 Some ( DeEvent :: Start ( e) ) => {
517- let end = e. name ( ) . to_owned ( ) ;
517+ let end = e. name ( ) . as_ref ( ) . to_owned ( ) ;
518518 let mut depth = 0 ;
519519 loop {
520520 let event = self . next ( ) ?;
521521 match event {
522- DeEvent :: Start ( ref e) if e. name ( ) == end => {
522+ DeEvent :: Start ( ref e) if e. name ( ) . as_ref ( ) == end => {
523523 self . skip_event ( event) ?;
524524 depth += 1 ;
525525 }
526- DeEvent :: End ( ref e) if e. name ( ) == end => {
526+ DeEvent :: End ( ref e) if e. name ( ) . as_ref ( ) == end => {
527527 self . skip_event ( event) ?;
528528 if depth == 0 {
529529 return Ok ( ( ) ) ;
@@ -571,7 +571,9 @@ where
571571 let e = self . next ( ) ?;
572572 match e {
573573 DeEvent :: Start ( e) => return Ok ( Some ( e) ) ,
574- DeEvent :: End ( e) => return Err ( DeError :: UnexpectedEnd ( e. name ( ) . to_owned ( ) ) ) ,
574+ DeEvent :: End ( e) => {
575+ return Err ( DeError :: UnexpectedEnd ( e. name ( ) . as_ref ( ) . to_owned ( ) ) )
576+ }
575577 DeEvent :: Eof => return Ok ( None ) ,
576578 _ => ( ) , // ignore texts
577579 }
@@ -631,20 +633,24 @@ where
631633 DeEvent :: Text ( t) if unescape => t. unescape ( ) ?,
632634 DeEvent :: Text ( t) => BytesCData :: new ( t. into_inner ( ) ) ,
633635 DeEvent :: CData ( t) => t,
634- DeEvent :: Start ( s) => return Err ( DeError :: UnexpectedStart ( s. name ( ) . to_owned ( ) ) ) ,
636+ DeEvent :: Start ( s) => {
637+ return Err ( DeError :: UnexpectedStart ( s. name ( ) . as_ref ( ) . to_owned ( ) ) )
638+ }
635639 // We can get End event in case of `<tag></tag>` or `<tag/>` input
636640 // Return empty text in that case
637641 DeEvent :: End ( end) if end. name ( ) == e. name ( ) => {
638642 return Ok ( BytesCData :: new ( & [ ] as & [ u8 ] ) ) ;
639643 }
640- DeEvent :: End ( end) => return Err ( DeError :: UnexpectedEnd ( end. name ( ) . to_owned ( ) ) ) ,
644+ DeEvent :: End ( end) => {
645+ return Err ( DeError :: UnexpectedEnd ( end. name ( ) . as_ref ( ) . to_owned ( ) ) )
646+ }
641647 DeEvent :: Eof => return Err ( DeError :: UnexpectedEof ) ,
642648 } ;
643- self . read_to_end ( e. name ( ) ) ?;
649+ self . read_to_end ( e. name ( ) . as_ref ( ) ) ?;
644650 Ok ( t)
645651 }
646- DeEvent :: Start ( e) => Err ( DeError :: UnexpectedStart ( e. name ( ) . to_owned ( ) ) ) ,
647- DeEvent :: End ( e) => Err ( DeError :: UnexpectedEnd ( e. name ( ) . to_owned ( ) ) ) ,
652+ DeEvent :: Start ( e) => Err ( DeError :: UnexpectedStart ( e. name ( ) . as_ref ( ) . to_owned ( ) ) ) ,
653+ DeEvent :: End ( e) => Err ( DeError :: UnexpectedEnd ( e. name ( ) . as_ref ( ) . to_owned ( ) ) ) ,
648654 DeEvent :: Eof => Err ( DeError :: UnexpectedEof ) ,
649655 }
650656 }
@@ -662,10 +668,10 @@ where
662668 let mut depth = 0 ;
663669 loop {
664670 match self . read . pop_front ( ) {
665- Some ( DeEvent :: Start ( e) ) if e. name ( ) == name => {
671+ Some ( DeEvent :: Start ( e) ) if e. name ( ) . as_ref ( ) == name => {
666672 depth += 1 ;
667673 }
668- Some ( DeEvent :: End ( e) ) if e. name ( ) == name => {
674+ Some ( DeEvent :: End ( e) ) if e. name ( ) . as_ref ( ) == name => {
669675 if depth == 0 {
670676 return Ok ( ( ) ) ;
671677 }
@@ -685,8 +691,8 @@ where
685691 fn read_to_end ( & mut self , name : & [ u8 ] ) -> Result < ( ) , DeError > {
686692 // First one might be in self.peek
687693 match self . next ( ) ? {
688- DeEvent :: Start ( e) => self . reader . read_to_end ( e. name ( ) ) ?,
689- DeEvent :: End ( e) if e. name ( ) == name => return Ok ( ( ) ) ,
694+ DeEvent :: Start ( e) => self . reader . read_to_end ( e. name ( ) . as_ref ( ) ) ?,
695+ DeEvent :: End ( e) if e. name ( ) . as_ref ( ) == name => return Ok ( ( ) ) ,
690696 _ => ( ) ,
691697 }
692698 self . reader . read_to_end ( name)
@@ -751,7 +757,7 @@ where
751757 {
752758 // Try to go to the next `<tag ...>...</tag>` or `<tag .../>`
753759 if let Some ( e) = self . next_start ( ) ? {
754- let name = e. name ( ) . to_vec ( ) ;
760+ let name = e. name ( ) . as_ref ( ) . to_vec ( ) ;
755761 let map = map:: MapAccess :: new ( self , e, fields) ?;
756762 let value = visitor. visit_map ( map) ?;
757763 self . read_to_end ( & name) ?;
@@ -785,11 +791,11 @@ where
785791 {
786792 match self . next ( ) ? {
787793 DeEvent :: Start ( s) => {
788- self . read_to_end ( s. name ( ) ) ?;
794+ self . read_to_end ( s. name ( ) . as_ref ( ) ) ?;
789795 visitor. visit_unit ( )
790796 }
791797 DeEvent :: Text ( _) | DeEvent :: CData ( _) => visitor. visit_unit ( ) ,
792- DeEvent :: End ( e) => Err ( DeError :: UnexpectedEnd ( e. name ( ) . to_owned ( ) ) ) ,
798+ DeEvent :: End ( e) => Err ( DeError :: UnexpectedEnd ( e. name ( ) . as_ref ( ) . to_owned ( ) ) ) ,
793799 DeEvent :: Eof => Err ( DeError :: UnexpectedEof ) ,
794800 }
795801 }
@@ -892,8 +898,8 @@ where
892898 V : Visitor < ' de > ,
893899 {
894900 match self . next ( ) ? {
895- DeEvent :: Start ( e) => self . read_to_end ( e. name ( ) ) ?,
896- DeEvent :: End ( e) => return Err ( DeError :: UnexpectedEnd ( e. name ( ) . to_owned ( ) ) ) ,
901+ DeEvent :: Start ( e) => self . read_to_end ( e. name ( ) . as_ref ( ) ) ?,
902+ DeEvent :: End ( e) => return Err ( DeError :: UnexpectedEnd ( e. name ( ) . as_ref ( ) . to_owned ( ) ) ) ,
897903 DeEvent :: Eof => return Err ( DeError :: UnexpectedEof ) ,
898904 _ => ( ) ,
899905 }
0 commit comments