This commit is contained in:
Svyatoslav Nikolsky
2017-05-01 17:11:45 +03:00
parent 91dc1ec366
commit 5f35ebd4eb
3 changed files with 58 additions and 5 deletions

View File

@ -267,11 +267,13 @@ macro_rules! impl_try_truncate_into {
impl TryTruncateInto<$into, Error> for $from {
fn try_truncate_into(self) -> Result<$into, Error> {
if !self.is_normal() {
println!("=== !IS_NORMAL: {}", self);
return Err(Error::Value("invalid float value for this operation".into()));
}
let truncated = self.trunc();
if truncated < $into::MIN as $from || truncated > $into::MAX as $from {
println!("=== {} < {} || {} > {}", truncated, $into::MIN, truncated, $into::MIN);
return Err(Error::Value("invalid float value for this operation".into()));
}