Fix type-error when calling parse_size from sort

This commit is contained in:
Gilad Naaman 2022-02-05 13:35:37 +02:00 committed by Omer Tuchfeld
parent 5d861df961
commit 8535cd41e0

View file

@ -33,6 +33,7 @@ use numeric_str_cmp::{human_numeric_str_cmp, numeric_str_cmp, NumInfo, NumInfoPa
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use rayon::prelude::*; use rayon::prelude::*;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::convert::TryFrom;
use std::env; use std::env;
use std::error::Error; use std::error::Error;
use std::ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
@ -354,7 +355,13 @@ impl GlobalSettings {
} else if size_string.ends_with('b') { } else if size_string.ends_with('b') {
size_string.pop(); size_string.pop();
} }
parse_size(&size_string) let size = parse_size(&size_string)?;
usize::try_from(size).map_err(|_| {
ParseSizeError::SizeTooBig(format!(
"Buffer size {} does not fit in address space",
size
))
})
} else { } else {
Err(ParseSizeError::ParseFailure("invalid suffix".to_string())) Err(ParseSizeError::ParseFailure("invalid suffix".to_string()))
} }