cli + query: improvements

This commit is contained in:
nym21
2025-03-02 20:15:01 +01:00
parent ceefc8ffc6
commit be2012f28d
15 changed files with 308 additions and 137 deletions
+5 -5
View File
@@ -325,15 +325,15 @@ where
}
});
let to = to.map_or(len, |to| {
let to = to.map_or(len - 1, |to| {
if to >= 0 {
to as usize
} else {
(len as i64 + to) as usize
((len - 1) as i64 + to) as usize
}
});
if from >= to {
if from > to {
return Err(Error::RangeFromAfterTo);
}
@@ -341,8 +341,8 @@ where
let mut buf = Self::create_buffer();
Ok((from..to)
.map(|_| Self::read_exact(&mut file, &mut buf).map(|v| v.to_owned()).unwrap())
Ok((from..=to)
.flat_map(|_| Self::read_exact(&mut file, &mut buf).map(|v| v.to_owned()))
.collect::<Vec<_>>())
}