summaryrefslogtreecommitdiff
path: root/src/model/str.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-11-04 09:30:44 +0100
committerLaurenz <laurmaedje@gmail.com>2022-11-04 11:38:09 +0100
commiteb951c008beea502042db4a3a0e8d1f8b51f6f52 (patch)
tree9856ee4ed0222222669de10e616a580b2a60135e /src/model/str.rs
parent33928a00dc58250e24da1dae4e5db17e7b598d70 (diff)
Style changes
Diffstat (limited to 'src/model/str.rs')
-rw-r--r--src/model/str.rs19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/model/str.rs b/src/model/str.rs
index 4aa40c54..1fcf7075 100644
--- a/src/model/str.rs
+++ b/src/model/str.rs
@@ -67,17 +67,13 @@ impl Str {
.ok_or_else(|| out_of_bounds(end, len))?
.max(start);
- Ok(self.0[start .. end].into())
+ Ok(self.0[start..end].into())
}
/// Resolve an index.
fn locate(&self, index: i64) -> Option<usize> {
- usize::try_from(if index >= 0 {
- index
- } else {
- self.len().checked_add(index)?
- })
- .ok()
+ usize::try_from(if index >= 0 { index } else { self.len().checked_add(index)? })
+ .ok()
}
/// Whether the given pattern exists in this string.
@@ -207,7 +203,7 @@ impl Str {
Some(StrPattern::Regex(re)) => {
let s = self.as_str();
let mut last = 0;
- let mut range = 0 .. s.len();
+ let mut range = 0..s.len();
for m in re.find_iter(s) {
// Does this match follow directly after the last one?
@@ -235,7 +231,7 @@ impl Str {
range.end = s.len();
}
- &s[range.start .. range.start.max(range.end)]
+ &s[range.start..range.start.max(range.end)]
}
};
@@ -271,10 +267,7 @@ impl Str {
/// The out of bounds access error message.
#[cold]
fn out_of_bounds(index: i64, len: i64) -> String {
- format!(
- "string index out of bounds (index: {}, len: {})",
- index, len
- )
+ format!("string index out of bounds (index: {}, len: {})", index, len)
}
/// Convert an item of std's `match_indices` to a dictionary.