File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 1414use crate :: fmt;
1515use crate :: ops:: Range ;
1616use crate :: iter:: FusedIterator ;
17+ use crate :: str:: from_utf8_unchecked;
1718
1819/// An iterator over the escaped version of a byte.
1920///
@@ -22,6 +23,7 @@ use crate::iter::FusedIterator;
2223///
2324/// [`escape_default`]: fn.escape_default.html
2425#[ stable( feature = "rust1" , since = "1.0.0" ) ]
26+ #[ derive( Clone ) ]
2527pub struct EscapeDefault {
2628 range : Range < usize > ,
2729 data : [ u8 ; 4 ] ,
@@ -130,6 +132,13 @@ impl ExactSizeIterator for EscapeDefault {}
130132#[ stable( feature = "fused" , since = "1.26.0" ) ]
131133impl FusedIterator for EscapeDefault { }
132134
135+ #[ stable( feature = "ascii_escape_display" , since = "1.39.0" ) ]
136+ impl fmt:: Display for EscapeDefault {
137+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
138+ f. write_str ( unsafe { from_utf8_unchecked ( & self . data [ self . range . clone ( ) ] ) } )
139+ }
140+ }
141+
133142#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
134143impl fmt:: Debug for EscapeDefault {
135144 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
You can’t perform that action at this time.
0 commit comments