Skip to content

Commit f5104ab

Browse files
committed
fix: backport fix from #59
1 parent f060748 commit f5104ab

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
22
name = "bytesize"
33
description = "an utility for human-readable bytes representations"
4-
version = "1.3.0"
4+
version = "1.3.1"
55
authors = ["Hyunsik Choi <[email protected]>"]
66

7-
homepage = "https://github.com/hyunsik/bytesize/"
7+
homepage = "https://github.com/bytesize-rs/bytesize/"
88
documentation = "https://docs.rs/bytesize/"
9-
repository = "https://github.com/hyunsik/bytesize/"
9+
repository = "https://github.com/bytesize-rs/bytesize/"
1010
readme = "README.md"
1111
keywords = ["byte", "byte-size", "utility", "human-readable", "format"]
1212
license = "Apache-2.0"

src/parse.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ impl std::str::FromStr for ByteSize {
1010
let number = take_while(value, |c| c.is_ascii_digit() || c == '.');
1111
match number.parse::<f64>() {
1212
Ok(v) => {
13-
let suffix = skip_while(value, |c| {
14-
c.is_whitespace() || c.is_ascii_digit() || c == '.'
15-
});
13+
let suffix = skip_while(value, char::is_whitespace);
1614
match suffix.parse::<Unit>() {
1715
Ok(u) => Ok(Self((v * u) as u64)),
1816
Err(error) => Err(format!(
@@ -220,6 +218,9 @@ mod tests {
220218

221219
assert!(parse("").is_err());
222220
assert!(parse("a124GB").is_err());
221+
assert!(parse("1.3 42.0 B").is_err());
222+
assert!(parse("1.3 ... B").is_err());
223+
assert!(parse("1 000 B").is_err());
223224
}
224225

225226
#[test]

0 commit comments

Comments
 (0)