File tree Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Expand file tree Collapse file tree 4 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 1
1
[package ]
2
2
name = " string_wizard"
3
- version = " 0.0.8 "
3
+ version = " 0.0.9 "
4
4
edition = " 2021"
5
5
license = " MIT"
6
6
description = " manipulate string like wizards"
Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ pub struct Chunk<'str> {
39
39
40
40
impl < ' s > Chunk < ' s > {
41
41
pub fn new ( span : Span ) -> Self {
42
- debug_assert ! ( span. 0 < span. 1 ) ;
43
42
Self {
44
43
span,
45
44
..Default :: default ( )
Original file line number Diff line number Diff line change @@ -63,6 +63,9 @@ impl<'text> MagicString<'text> {
63
63
let start = start. assert_into_u32 ( ) ;
64
64
let end = end. assert_into_u32 ( ) ;
65
65
let to = to. assert_into_u32 ( ) ;
66
+ if to >= start && to <= end {
67
+ panic ! ( "Cannot relocate a selection inside itself" )
68
+ }
66
69
67
70
self . split_at ( start) ;
68
71
self . split_at ( end) ;
Original file line number Diff line number Diff line change @@ -287,4 +287,13 @@ mod misc {
287
287
assert_eq ! ( s. remove( 0 , 3 ) . to_string( ) , "3456" ) ;
288
288
assert_eq ! ( s. remove( 3 , 7 ) . to_string( ) , "" ) ;
289
289
}
290
+
291
+ #[ test]
292
+ fn allow_empty_input ( ) {
293
+ let mut s = MagicString :: new ( "" ) ;
294
+ s. append ( "xyz" ) ;
295
+ assert_eq ! ( s. to_string( ) , "xyz" ) ;
296
+ s. prepend ( "xyz" ) ;
297
+ assert_eq ! ( s. to_string( ) , "xyzxyz" ) ;
298
+ }
290
299
}
You can’t perform that action at this time.
0 commit comments