@@ -775,10 +775,10 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
775775 reason = "recently added" ,
776776 issue = "62482" ) ]
777777 pub fn key ( & mut self , key : & dyn fmt:: Debug ) -> & mut DebugMap < ' a , ' b > {
778- assert ! ( !self . has_key, "attempted to begin a new map entry \
779- without completing the previous one") ;
780-
781778 self . result = self . result . and_then ( |_| {
779+ assert ! ( !self . has_key, "attempted to begin a new map entry \
780+ without completing the previous one") ;
781+
782782 if self . is_pretty ( ) {
783783 if !self . has_fields {
784784 self . fmt . write_str ( "\n " ) ?;
@@ -839,9 +839,9 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
839839 reason = "recently added" ,
840840 issue = "62482" ) ]
841841 pub fn value ( & mut self , value : & dyn fmt:: Debug ) -> & mut DebugMap < ' a , ' b > {
842- assert ! ( self . has_key, "attempted to format a map value before its key" ) ;
843-
844842 self . result = self . result . and_then ( |_| {
843+ assert ! ( self . has_key, "attempted to format a map value before its key" ) ;
844+
845845 if self . is_pretty ( ) {
846846 let mut slot = None ;
847847 let mut writer = PadAdapter :: wrap ( & mut self . fmt , & mut slot, & mut self . state ) ;
@@ -924,9 +924,11 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
924924 /// ```
925925 #[ stable( feature = "debug_builders" , since = "1.2.0" ) ]
926926 pub fn finish ( & mut self ) -> fmt:: Result {
927- assert ! ( !self . has_key, "attempted to finish a map with a partial entry" ) ;
927+ self . result . and_then ( |_| {
928+ assert ! ( !self . has_key, "attempted to finish a map with a partial entry" ) ;
928929
929- self . result . and_then ( |_| self . fmt . write_str ( "}" ) )
930+ self . fmt . write_str ( "}" )
931+ } )
930932 }
931933
932934 fn is_pretty ( & self ) -> bool {
0 commit comments