diff options
author | Aleksey Kladov <[email protected]> | 2019-01-08 18:50:04 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-08 18:50:04 +0000 |
commit | f553837c1ca30a52bf5091689c21d3c3e3362395 (patch) | |
tree | 79dbabf6137e6aaf64d494f57a7cecbf397237bc /crates/ra_syntax/src/text_utils.rs | |
parent | c9e42fcf245be16958dca6571e4bccc6c29199df (diff) |
upstream text-utils to text_unit
Diffstat (limited to 'crates/ra_syntax/src/text_utils.rs')
-rw-r--r-- | crates/ra_syntax/src/text_utils.rs | 10 |
1 files changed, 0 insertions, 10 deletions
diff --git a/crates/ra_syntax/src/text_utils.rs b/crates/ra_syntax/src/text_utils.rs index 417d43e1b..7aaf4c223 100644 --- a/crates/ra_syntax/src/text_utils.rs +++ b/crates/ra_syntax/src/text_utils.rs | |||
@@ -1,15 +1,5 @@ | |||
1 | use crate::TextRange; | 1 | use crate::TextRange; |
2 | 2 | ||
3 | pub fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> { | ||
4 | let start = r1.start().max(r2.start()); | ||
5 | let end = r1.end().min(r2.end()); | ||
6 | if start <= end { | ||
7 | Some(TextRange::from_to(start, end)) | ||
8 | } else { | ||
9 | None | ||
10 | } | ||
11 | } | ||
12 | |||
13 | pub fn replace_range(mut text: String, range: TextRange, replace_with: &str) -> String { | 3 | pub fn replace_range(mut text: String, range: TextRange, replace_with: &str) -> String { |
14 | let start = u32::from(range.start()) as usize; | 4 | let start = u32::from(range.start()) as usize; |
15 | let end = u32::from(range.end()) as usize; | 5 | let end = u32::from(range.end()) as usize; |