Clean up clippy.
This commit is contained in:
@@ -980,8 +980,8 @@ impl Engine {
|
||||
})?,
|
||||
offset,
|
||||
)
|
||||
} else if let Some(abs_index) = index.checked_abs() {
|
||||
let offset = abs_index as usize;
|
||||
} else {
|
||||
let offset = index.unsigned_abs() as usize;
|
||||
(
|
||||
// Count from end if negative
|
||||
s.chars().rev().nth(offset - 1).ok_or_else(|| {
|
||||
@@ -990,9 +990,6 @@ impl Engine {
|
||||
})?,
|
||||
offset,
|
||||
)
|
||||
} else {
|
||||
let chars_len = s.chars().count();
|
||||
return Err(ERR::ErrorStringBounds(chars_len, index, idx_pos).into());
|
||||
};
|
||||
|
||||
Ok(Target::StringChar {
|
||||
|
@@ -441,7 +441,6 @@ impl Engine {
|
||||
///
|
||||
/// It is up to the [`Engine`] to reactivate the debugger.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub(crate) fn run_debugger_with_reset<'a>(
|
||||
&self,
|
||||
scope: &mut Scope,
|
||||
@@ -464,7 +463,6 @@ impl Engine {
|
||||
///
|
||||
/// It is up to the [`Engine`] to reactivate the debugger.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub(crate) fn run_debugger_with_reset_raw<'a>(
|
||||
&self,
|
||||
scope: &mut Scope,
|
||||
@@ -514,7 +512,6 @@ impl Engine {
|
||||
///
|
||||
/// It is up to the [`Engine`] to reactivate the debugger.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub(crate) fn run_debugger_raw<'a>(
|
||||
&self,
|
||||
scope: &mut Scope,
|
||||
|
@@ -15,9 +15,7 @@ use std::prelude::v1::*;
|
||||
#[allow(dead_code)]
|
||||
pub fn calc_offset_len(length: usize, start: crate::INT, len: crate::INT) -> (usize, usize) {
|
||||
let start = if start < 0 {
|
||||
start.checked_abs().map_or(0, |positive_start| {
|
||||
length - usize::min(positive_start as usize, length)
|
||||
})
|
||||
length - usize::min(start.unsigned_abs() as usize, length)
|
||||
} else if start as usize >= length {
|
||||
return (length, 0);
|
||||
} else {
|
||||
@@ -50,20 +48,14 @@ pub fn calc_index<E>(
|
||||
) -> Result<usize, E> {
|
||||
if start < 0 {
|
||||
if negative_count_from_end {
|
||||
let abs_start = start.unsigned_abs() as usize;
|
||||
|
||||
// Count from end if negative
|
||||
#[cfg(not(feature = "unchecked"))]
|
||||
return match start.checked_abs() {
|
||||
Some(positive_start) => {
|
||||
if (positive_start as usize) > length {
|
||||
err()
|
||||
} else {
|
||||
Ok(length - (positive_start as usize))
|
||||
}
|
||||
}
|
||||
None => err(),
|
||||
};
|
||||
#[cfg(feature = "unchecked")]
|
||||
return Ok(length - (start.abs() as usize));
|
||||
if abs_start > length {
|
||||
err()
|
||||
} else {
|
||||
Ok(length - abs_start)
|
||||
}
|
||||
} else {
|
||||
err()
|
||||
}
|
||||
|
Reference in New Issue
Block a user