diff options
Diffstat (limited to 'crates/libsyntax2/src/text_utils.rs')
-rw-r--r-- | crates/libsyntax2/src/text_utils.rs | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/crates/libsyntax2/src/text_utils.rs b/crates/libsyntax2/src/text_utils.rs deleted file mode 100644 index 58ae1e43e..000000000 --- a/crates/libsyntax2/src/text_utils.rs +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | use {TextRange, TextUnit}; | ||
2 | |||
3 | pub fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool { | ||
4 | range.start() <= offset && offset <= range.end() | ||
5 | } | ||
6 | |||
7 | pub fn is_subrange(range: TextRange, subrange: TextRange) -> bool { | ||
8 | range.start() <= subrange.start() && subrange.end() <= range.end() | ||
9 | } | ||
10 | |||
11 | pub fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> { | ||
12 | let start = r1.start().max(r2.start()); | ||
13 | let end = r1.end().min(r2.end()); | ||
14 | if start <= end { | ||
15 | Some(TextRange::from_to(start, end)) | ||
16 | } else { | ||
17 | None | ||
18 | } | ||
19 | } | ||
20 | |||
21 | pub fn replace_range(mut text: String, range: TextRange, replace_with: &str) -> String { | ||
22 | let start = u32::from(range.start()) as usize; | ||
23 | let end = u32::from(range.end()) as usize; | ||
24 | text.replace_range(start..end, replace_with); | ||
25 | text | ||
26 | } \ No newline at end of file | ||