aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/text_utils.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-16 10:54:24 +0100
committerAleksey Kladov <[email protected]>2018-09-16 11:07:39 +0100
commitb5021411a84822cb3f1e3aeffad9550dd15bdeb6 (patch)
tree9dca564f8e51b298dced01c4ce669c756dce3142 /crates/libsyntax2/src/text_utils.rs
parentba0bfeee12e19da40b5eabc8d0408639af10e96f (diff)
rename all things
Diffstat (limited to 'crates/libsyntax2/src/text_utils.rs')
-rw-r--r--crates/libsyntax2/src/text_utils.rs26
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 @@
1use {TextRange, TextUnit};
2
3pub fn contains_offset_nonstrict(range: TextRange, offset: TextUnit) -> bool {
4 range.start() <= offset && offset <= range.end()
5}
6
7pub fn is_subrange(range: TextRange, subrange: TextRange) -> bool {
8 range.start() <= subrange.start() && subrange.end() <= range.end()
9}
10
11pub 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
21pub 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