From 065e5eab4a0278b77bd0b14167a662776f491921 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Sat, 17 Nov 2018 14:50:33 +0100 Subject: Improve value conversion --- src/interface.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interface.rs b/src/interface.rs index 74d175f..d22f776 100644 --- a/src/interface.rs +++ b/src/interface.rs @@ -78,7 +78,7 @@ where self.i2c .write_read(self.address, &[register], &mut data) .map_err(Error::Comm) - .and(Ok(((data[0] as u16) << 8) | data[1] as u16)) + .and(Ok((u16::from(data[0]) << 8) | u16::from(data[1]))) } } @@ -96,6 +96,6 @@ where .map_err(Error::Comm); self.cs.set_high(); let result = result?; - Ok(((result[0] as u16) << 8) | result[1] as u16) + Ok((u16::from(result[0]) << 8) | u16::from(result[1])) } } -- cgit v1.2.3-54-g00ecf