From 5470d8fc702cc06a31335a196c10a5b8daf821c1 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Wed, 5 Feb 2025 18:53:47 +0100 Subject: [PATCH] Fix unused code warnings on other platforms --- examples/nunchuck.rs | 4 ++++ examples/pca9956b.rs | 15 +++++++++------ examples/sensors.rs | 14 ++++++++------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/examples/nunchuck.rs b/examples/nunchuck.rs index 9af0242c..7462311f 100644 --- a/examples/nunchuck.rs +++ b/examples/nunchuck.rs @@ -57,6 +57,7 @@ mod nunchuck { // TODO: Move Nunchuck code out to be an actual sensor and add tests #[derive(Debug)] + #[allow(dead_code)] pub struct NunchuckReading { pub joystick_x: u8, pub joystick_y: u8, @@ -186,9 +187,12 @@ mod nunchuck { #[cfg(any(target_os = "linux", target_os = "android"))] use nunchuck::*; +#[cfg(any(target_os = "linux", target_os = "android"))] use docopt::Docopt; +#[cfg(any(target_os = "linux", target_os = "android"))] use std::env::args; +#[cfg(any(target_os = "linux", target_os = "android"))] const USAGE: &str = " Reading Wii Nunchuck data via Linux i2cdev. diff --git a/examples/pca9956b.rs b/examples/pca9956b.rs index c6661f59..66a9d00f 100644 --- a/examples/pca9956b.rs +++ b/examples/pca9956b.rs @@ -10,13 +10,12 @@ extern crate docopt; extern crate i2cdev; #[cfg(any(target_os = "linux", target_os = "android"))] -use i2cdev::core::{I2CMessage, I2CTransfer}; -#[cfg(any(target_os = "linux", target_os = "android"))] -use i2cdev::linux::{LinuxI2CBus, LinuxI2CMessage}; - -use docopt::Docopt; -use std::env::args; +use i2cdev::{ + core::{I2CMessage, I2CTransfer}, + linux::{LinuxI2CBus, LinuxI2CMessage}, +}; +#[cfg(any(target_os = "linux", target_os = "android"))] const USAGE: &str = " Reads registers from a PCA9956B IC via Linux i2cdev. @@ -32,6 +31,7 @@ Options: --version Show version. "; +#[cfg(any(target_os = "linux", target_os = "android"))] const ADDR: u16 = 0x20; #[cfg(not(any(target_os = "linux", target_os = "android")))] @@ -39,6 +39,9 @@ fn main() {} #[cfg(any(target_os = "linux", target_os = "android"))] fn main() { + use docopt::Docopt; + use std::env::args; + let args = Docopt::new(USAGE) .and_then(|d| d.argv(args()).parse()) .unwrap_or_else(|e| e.exit()); diff --git a/examples/sensors.rs b/examples/sensors.rs index 4fc9c0cb..1a52c591 100644 --- a/examples/sensors.rs +++ b/examples/sensors.rs @@ -17,13 +17,15 @@ extern crate byteorder; extern crate docopt; extern crate i2cdev; +#[cfg(any(target_os = "linux", target_os = "android"))] use docopt::Docopt; -use sensors::adxl345_accelerometer::*; -use sensors::mpl115a2_barometer::*; -use sensors::{Accelerometer, Barometer, Thermometer}; -use std::env::args; -use std::thread; -use std::time::Duration; +#[cfg(any(target_os = "linux", target_os = "android"))] +use sensors::{ + adxl345_accelerometer::*, mpl115a2_barometer::*, Accelerometer, Barometer, Thermometer, +}; + +#[cfg(any(target_os = "linux", target_os = "android"))] +use std::{env::args, thread, time::Duration}; #[cfg(any(target_os = "linux", target_os = "android"))] use i2cdev::linux::*;