aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/text_utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/libsyntax2/src/text_utils.rs')
-rw-r--r--crates/libsyntax2/src/text_utils.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/libsyntax2/src/text_utils.rs b/crates/libsyntax2/src/text_utils.rs
index e3d73888f..58ae1e43e 100644
--- a/crates/libsyntax2/src/text_utils.rs
+++ b/crates/libsyntax2/src/text_utils.rs
@@ -17,3 +17,10 @@ pub fn intersect(r1: TextRange, r2: TextRange) -> Option<TextRange> {
17 None 17 None
18 } 18 }
19} 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