removed two ParseError variants and renamed one
This commit is contained in:
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
## Upcoming
|
## Upcoming
|
||||||
|
|
||||||
- Added method `Beatmap::from_path` so the file does not have to be created manually for `Beatmap::parse`
|
- Added method `Beatmap::from_path` so the file does not have to be created manually for `Beatmap::parse`.
|
||||||
|
- [BREAKING] Removed the `ParseError` variants `InvalidPathType` and `InvalidTimingSignature` and renamed `InvalidFloatingPoint` to `InvalidDecimalNumber`.
|
||||||
|
|
||||||
# v0.3.0
|
# v0.3.0
|
||||||
|
|
||||||
|
|||||||
+5
-13
@@ -28,16 +28,12 @@ pub enum ParseError {
|
|||||||
BadLine,
|
BadLine,
|
||||||
/// Line in `.osu` that contains a slider was not in the proper format.
|
/// Line in `.osu` that contains a slider was not in the proper format.
|
||||||
InvalidCurvePoints,
|
InvalidCurvePoints,
|
||||||
|
/// Expected a decimal number, got something else.
|
||||||
|
InvalidDecimalNumber,
|
||||||
/// Expected an integer, got something else.
|
/// Expected an integer, got something else.
|
||||||
InvalidInteger,
|
InvalidInteger,
|
||||||
/// Expected a decimal number, got something else.
|
|
||||||
InvalidFloatingPoint,
|
|
||||||
/// Failed to parse game mode.
|
/// Failed to parse game mode.
|
||||||
InvalidMode,
|
InvalidMode,
|
||||||
/// Failed to parse the path type of a slider.
|
|
||||||
InvalidPathType,
|
|
||||||
/// Failed to parse timing point.
|
|
||||||
InvalidTimingSignature,
|
|
||||||
/// Expected an additional field.
|
/// Expected an additional field.
|
||||||
MissingField(&'static str),
|
MissingField(&'static str),
|
||||||
/// Reject maps with too many repeat points.
|
/// Reject maps with too many repeat points.
|
||||||
@@ -65,10 +61,8 @@ impl fmt::Display for ParseError {
|
|||||||
Self::BadLine => f.write_str("line not in `Key:Value` pattern"),
|
Self::BadLine => f.write_str("line not in `Key:Value` pattern"),
|
||||||
Self::InvalidCurvePoints => f.write_str("invalid curve point"),
|
Self::InvalidCurvePoints => f.write_str("invalid curve point"),
|
||||||
Self::InvalidInteger => f.write_str("invalid integer"),
|
Self::InvalidInteger => f.write_str("invalid integer"),
|
||||||
Self::InvalidFloatingPoint => f.write_str("invalid float number"),
|
Self::InvalidDecimalNumber => f.write_str("invalid float number"),
|
||||||
Self::InvalidMode => f.write_str("invalid mode"),
|
Self::InvalidMode => f.write_str("invalid mode"),
|
||||||
Self::InvalidPathType => f.write_str("invalid path type"),
|
|
||||||
Self::InvalidTimingSignature => f.write_str("invalid timing signature"),
|
|
||||||
Self::MissingField(field) => write!(f, "missing field `{}`", field),
|
Self::MissingField(field) => write!(f, "missing field `{}`", field),
|
||||||
Self::TooManyRepeats => f.write_str("repeat count is way too high"),
|
Self::TooManyRepeats => f.write_str("repeat count is way too high"),
|
||||||
Self::UnknownHitObjectKind => f.write_str("unsupported hitobject kind"),
|
Self::UnknownHitObjectKind => f.write_str("unsupported hitobject kind"),
|
||||||
@@ -96,10 +90,8 @@ impl StdError for ParseError {
|
|||||||
Self::BadLine => None,
|
Self::BadLine => None,
|
||||||
Self::InvalidCurvePoints => None,
|
Self::InvalidCurvePoints => None,
|
||||||
Self::InvalidInteger => None,
|
Self::InvalidInteger => None,
|
||||||
Self::InvalidFloatingPoint => None,
|
Self::InvalidDecimalNumber => None,
|
||||||
Self::InvalidMode => None,
|
Self::InvalidMode => None,
|
||||||
Self::InvalidPathType => None,
|
|
||||||
Self::InvalidTimingSignature => None,
|
|
||||||
Self::MissingField(_) => None,
|
Self::MissingField(_) => None,
|
||||||
Self::TooManyRepeats => None,
|
Self::TooManyRepeats => None,
|
||||||
Self::UnknownHitObjectKind => None,
|
Self::UnknownHitObjectKind => None,
|
||||||
@@ -129,6 +121,6 @@ impl From<ParseIntError> for ParseError {
|
|||||||
|
|
||||||
impl From<ParseFloatError> for ParseError {
|
impl From<ParseFloatError> for ParseError {
|
||||||
fn from(_: ParseFloatError) -> Self {
|
fn from(_: ParseFloatError) -> Self {
|
||||||
Self::InvalidFloatingPoint
|
Self::InvalidDecimalNumber
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ impl FloatExt for f64 {
|
|||||||
fn validate(self) -> Result<Self, ParseError> {
|
fn validate(self) -> Result<Self, ParseError> {
|
||||||
self.is_finite()
|
self.is_finite()
|
||||||
.then(|| self)
|
.then(|| self)
|
||||||
.ok_or(ParseError::InvalidFloatingPoint)
|
.ok_or(ParseError::InvalidDecimalNumber)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user