We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5af3d66 + a9f6f4b commit ad73cb0Copy full SHA for ad73cb0
src/libcore/num/mod.rs
@@ -1672,6 +1672,7 @@ macro_rules! from_str_radix_int_impl {
1672
let is_signed_ty = (0 as $T) > Int::min_value();
1673
1674
match src.slice_shift_char() {
1675
+ Some(('-', "")) => Err(PIE { kind: Empty }),
1676
Some(('-', src)) if is_signed_ty => {
1677
// The number is negative
1678
let mut result = 0;
src/libcoretest/num/mod.rs
@@ -122,4 +122,9 @@ mod test {
122
assert_eq!("-9223372036854775808".parse::<i64>().ok(), Some(i64_val));
123
assert_eq!("-9223372036854775809".parse::<i64>().ok(), None);
124
}
125
+
126
+ #[test]
127
+ fn test_int_from_minus_sign() {
128
+ assert_eq!("-".parse::<i32>().ok(), None);
129
+ }
130
0 commit comments