mirror of
https://github.com/nushell/nushell.git
synced 2025-01-03 04:50:28 +01:00
Fixed clippy errors
This commit is contained in:
parent
69f373850f
commit
cac6998708
@ -140,7 +140,25 @@ fn map_value(input: &Value, args: &Arguments, head: Span) -> Value {
|
||||
match input {
|
||||
Value::Binary { val, .. } => {
|
||||
let len = val.len() as u64;
|
||||
let start: usize = range.absolute_start(len).try_into().unwrap();
|
||||
let start: u64 = range.absolute_start(len);
|
||||
let start: usize = match start.try_into() {
|
||||
Ok(start) => start,
|
||||
Err(_) => {
|
||||
let span = input.span();
|
||||
return Value::error(
|
||||
ShellError::UnsupportedInput {
|
||||
msg: format!(
|
||||
"Absolute start position {start} was too large for your system arch."
|
||||
),
|
||||
input: args.range.to_string(),
|
||||
msg_span: span,
|
||||
input_span: span,
|
||||
},
|
||||
head,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
let bytes: Vec<u8> = match range.absolute_end(len) {
|
||||
Bound::Unbounded => val[start..].into(),
|
||||
Bound::Included(end) => val[start..=end as usize].into(),
|
||||
|
@ -81,10 +81,11 @@ mod int_range {
|
||||
self.start
|
||||
}
|
||||
|
||||
// Resolves the absolute start position given the length of the input value
|
||||
pub fn absolute_start(&self, len: u64) -> u64 {
|
||||
let max_index = len - 1;
|
||||
match self.start {
|
||||
start if start < 0 => len.saturating_sub(start.unsigned_abs().into()),
|
||||
start if start < 0 => len.saturating_sub(start.unsigned_abs()),
|
||||
start => max_index.min(start as u64),
|
||||
}
|
||||
}
|
||||
@ -110,11 +111,11 @@ mod int_range {
|
||||
match self.end {
|
||||
Bound::Unbounded => Bound::Unbounded,
|
||||
Bound::Included(i) => Bound::Included(match i {
|
||||
i if i < 0 => len.saturating_sub(i.unsigned_abs() as u64),
|
||||
i if i < 0 => len.saturating_sub(i.unsigned_abs()),
|
||||
i => max_index.min(i as u64),
|
||||
}),
|
||||
Bound::Excluded(i) => Bound::Excluded(match i {
|
||||
i if i < 0 => len.saturating_sub(i.unsigned_abs() as u64),
|
||||
i if i < 0 => len.saturating_sub(i.unsigned_abs()),
|
||||
i => len.min(i as u64),
|
||||
}),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user