Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: ParseFloatError
Hi, I was trying to convert string to f64 and I try to seperate reason for parse error.
match value.parse() {
Ok(value) => Ok(value),
Err(source) => match source {
// and here is problem, because I can't get error kind.
}
}
Looking at source code of f64 parse I see
pub struct ParseFloatError {
kind: FloatErrorKind,
}
enum FloatErrorKind {
Empty,
Invalid,
}
ParseFloatError is public, but kind is private. Even FloatErrorKind is private.
Here are no way to get kind from error, not compare it with FloatErrorKind
Why is it so?
I think error kinds should be public, so user could check which error he got.
One of reasons to check would be error translation from English to other langues.
2 posts - 2 participants
🏷️ rust_feed