From f03bac6c3acea5492160558dd731d77341e1cf22 Mon Sep 17 00:00:00 2001 From: mcarton Date: Sun, 2 Oct 2016 02:47:23 +0200 Subject: [PATCH] Remove a useless method --- clippy_lints/src/consts.rs | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index fa3e6a156..19149671e 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -54,27 +54,16 @@ pub enum Constant { } impl Constant { - /// convert to u64 if possible + /// Convert to `u64` if possible. /// /// # panics /// - /// if the constant could not be converted to u64 losslessly + /// If the constant could not be converted to `u64` losslessly. fn as_u64(&self) -> u64 { if let Constant::Int(val) = *self { - val.to_u64().expect("negative constant can't be casted to u64") + val.to_u64().expect("negative constant can't be casted to `u64`") } else { - panic!("Could not convert a {:?} to u64", self); - } - } - - /// convert this constant to a f64, if possible - #[allow(cast_precision_loss, cast_possible_wrap)] - pub fn as_float(&self) -> Option { - match *self { - Constant::Float(ref s, _) => s.parse().ok(), - Constant::Int(i) if i.is_negative() => Some(i.to_u64_unchecked() as i64 as f64), - Constant::Int(i) => Some(i.to_u64_unchecked() as f64), - _ => None, + panic!("Could not convert a `{:?}` to `u64`", self); } } }