File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 14
14
use crate :: fmt;
15
15
use crate :: ops:: Range ;
16
16
use crate :: iter:: FusedIterator ;
17
+ use crate :: str:: from_utf8_unchecked;
17
18
18
19
/// An iterator over the escaped version of a byte.
19
20
///
@@ -22,6 +23,7 @@ use crate::iter::FusedIterator;
22
23
///
23
24
/// [`escape_default`]: fn.escape_default.html
24
25
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
26
+ #[ derive( Clone ) ]
25
27
pub struct EscapeDefault {
26
28
range : Range < usize > ,
27
29
data : [ u8 ; 4 ] ,
@@ -130,6 +132,13 @@ impl ExactSizeIterator for EscapeDefault {}
130
132
#[ stable( feature = "fused" , since = "1.26.0" ) ]
131
133
impl FusedIterator for EscapeDefault { }
132
134
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
+
133
142
#[ stable( feature = "std_debug" , since = "1.16.0" ) ]
134
143
impl fmt:: Debug for EscapeDefault {
135
144
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
You can’t perform that action at this time.
0 commit comments