Skip to content

Commit

Permalink
fix TryFrom impl (was causing a stackoverflow)
Browse files Browse the repository at this point in the history
  • Loading branch information
shelvacu committed Sep 16, 2021
1 parent f97813f commit 57895ff
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,9 @@ macro_rules! impl_ranged {
Err(_) => return Err(TryFromIntError)
};

if value < MIN || value > MAX {
Err(TryFromIntError)
} else {
match TryFrom::try_from(value) {
Ok(value) => Ok(value),
Err(_) => Err(TryFromIntError),
}
match Self::new(value) {
None => Err(TryFromIntError),
Some(v) => Ok(v),
}
}
})*
Expand Down

0 comments on commit 57895ff

Please sign in to comment.