@@ -24,7 +24,7 @@ impl State {
24
24
}
25
25
26
26
/// Span with a change [`State`].
27
- #[ derive( Debug , Clone , PartialEq , Eq ) ]
27
+ #[ derive( Clone , PartialEq , Eq ) ]
28
28
struct Span {
29
29
/// Start of this span in parent data
30
30
start : usize ,
@@ -34,6 +34,17 @@ struct Span {
34
34
data : State ,
35
35
}
36
36
37
+ impl std:: fmt:: Debug for Span {
38
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
39
+ let state = match self . data {
40
+ State :: Initial => "initial" ,
41
+ State :: Replaced ( _) => "replaced" ,
42
+ State :: Inserted ( _) => "inserted" ,
43
+ } ;
44
+ write ! ( f, "({}, {}: {state})" , self . start, self . end)
45
+ }
46
+ }
47
+
37
48
/// A container that allows easily replacing chunks of its data
38
49
#[ derive( Debug , Clone , Default ) ]
39
50
pub struct Data {
@@ -102,30 +113,12 @@ impl Data {
102
113
. iter ( )
103
114
. position ( |p| !p. data . is_inserted ( ) && p. start <= range. start && p. end >= range. end )
104
115
else {
105
- if tracing:: enabled!( tracing:: Level :: DEBUG ) {
106
- let slices = self
107
- . parts
108
- . iter ( )
109
- . map ( |p| {
110
- (
111
- p. start ,
112
- p. end ,
113
- match p. data {
114
- State :: Initial => "initial" ,
115
- State :: Replaced ( ..) => "replaced" ,
116
- State :: Inserted ( ..) => "inserted" ,
117
- } ,
118
- )
119
- } )
120
- . collect :: < Vec < _ > > ( ) ;
121
- tracing:: debug!(
122
- "no single slice covering {}..{}, current slices: {:?}" ,
123
- range. start,
124
- range. end,
125
- slices,
126
- ) ;
127
- }
128
-
116
+ tracing:: debug!(
117
+ "no single slice covering {}..{}, current slices: {:?}" ,
118
+ range. start,
119
+ range. end,
120
+ self . parts,
121
+ ) ;
129
122
return Err ( Error :: MaybeAlreadyReplaced ( range) ) ;
130
123
} ;
131
124
0 commit comments