Skip to content

Commit daa01ed

Browse files
committed
Fix unused code warnings on other platforms
1 parent eaba606 commit daa01ed

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

examples/nunchuck.rs

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ mod nunchuck {
5757
// TODO: Move Nunchuck code out to be an actual sensor and add tests
5858

5959
#[derive(Debug)]
60+
#[allow(dead_code)]
6061
pub struct NunchuckReading {
6162
pub joystick_x: u8,
6263
pub joystick_y: u8,
@@ -186,9 +187,12 @@ mod nunchuck {
186187
#[cfg(any(target_os = "linux", target_os = "android"))]
187188
use nunchuck::*;
188189

190+
#[cfg(any(target_os = "linux", target_os = "android"))]
189191
use docopt::Docopt;
192+
#[cfg(any(target_os = "linux", target_os = "android"))]
190193
use std::env::args;
191194

195+
#[cfg(any(target_os = "linux", target_os = "android"))]
192196
const USAGE: &str = "
193197
Reading Wii Nunchuck data via Linux i2cdev.
194198

examples/pca9956b.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ extern crate docopt;
1010
extern crate i2cdev;
1111

1212
#[cfg(any(target_os = "linux", target_os = "android"))]
13-
use i2cdev::core::{I2CMessage, I2CTransfer};
14-
#[cfg(any(target_os = "linux", target_os = "android"))]
15-
use i2cdev::linux::{LinuxI2CBus, LinuxI2CMessage};
16-
17-
use docopt::Docopt;
18-
use std::env::args;
13+
use i2cdev::{
14+
core::{I2CMessage, I2CTransfer},
15+
linux::{LinuxI2CBus, LinuxI2CMessage},
16+
};
1917

18+
#[cfg(any(target_os = "linux", target_os = "android"))]
2019
const USAGE: &str = "
2120
Reads registers from a PCA9956B IC via Linux i2cdev.
2221
@@ -32,13 +31,17 @@ Options:
3231
--version Show version.
3332
";
3433

34+
#[cfg(any(target_os = "linux", target_os = "android"))]
3535
const ADDR: u16 = 0x20;
3636

3737
#[cfg(not(any(target_os = "linux", target_os = "android")))]
3838
fn main() {}
3939

4040
#[cfg(any(target_os = "linux", target_os = "android"))]
4141
fn main() {
42+
use docopt::Docopt;
43+
use std::env::args;
44+
4245
let args = Docopt::new(USAGE)
4346
.and_then(|d| d.argv(args()).parse())
4447
.unwrap_or_else(|e| e.exit());

examples/sensors.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ extern crate byteorder;
1717
extern crate docopt;
1818
extern crate i2cdev;
1919

20+
#[cfg(any(target_os = "linux", target_os = "android"))]
2021
use docopt::Docopt;
21-
use sensors::adxl345_accelerometer::*;
22-
use sensors::mpl115a2_barometer::*;
23-
use sensors::{Accelerometer, Barometer, Thermometer};
24-
use std::env::args;
25-
use std::thread;
26-
use std::time::Duration;
22+
#[cfg(any(target_os = "linux", target_os = "android"))]
23+
use sensors::{
24+
adxl345_accelerometer::*, mpl115a2_barometer::*, Accelerometer, Barometer, Thermometer,
25+
};
26+
27+
#[cfg(any(target_os = "linux", target_os = "android"))]
28+
use std::{env::args, thread, time::Duration};
2729

2830
#[cfg(any(target_os = "linux", target_os = "android"))]
2931
use i2cdev::linux::*;

0 commit comments

Comments
 (0)