Skip to content

Commit 955b385

Browse files
committed
doctest: add target_os gates to fix test compilation on macos
1 parent 6bb9361 commit 955b385

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
//! use std::time::Duration;
2525
//!
2626
//! use i2cdev::core::*;
27+
//! #[cfg(any(target_os = "linux", target_os = "android"))]
2728
//! use i2cdev::linux::{LinuxI2CDevice, LinuxI2CError};
2829
//!
2930
//! const NUNCHUCK_SLAVE_ADDR: u16 = 0x52;
3031
//!
3132
//! // real code should probably not use unwrap()
33+
//! #[cfg(any(target_os = "linux", target_os = "android"))]
3234
//! fn i2cfun() -> Result<(), LinuxI2CError> {
3335
//! let mut dev = LinuxI2CDevice::new("/dev/i2c-1", NUNCHUCK_SLAVE_ADDR)?;
3436
//!
@@ -52,10 +54,12 @@
5254
//! extern crate i2cdev;
5355
//!
5456
//! use i2cdev::core::*;
57+
//! #[cfg(any(target_os = "linux", target_os = "android"))]
5558
//! use i2cdev::linux::{LinuxI2CDevice, LinuxI2CError, LinuxI2CMessage};
5659
//!
5760
//! const SLAVE_ADDR: u16 = 0x57;
5861
//!
62+
//! #[cfg(any(target_os = "linux", target_os = "android"))]
5963
//! fn write_read_transaction() -> Result<(), LinuxI2CError> {
6064
//! let mut dev = LinuxI2CDevice::new("/dev/i2c-1", SLAVE_ADDR)?;
6165
//!
@@ -76,10 +80,12 @@
7680
//! extern crate i2cdev;
7781
//!
7882
//! use i2cdev::core::*;
83+
//! #[cfg(any(target_os = "linux", target_os = "android"))]
7984
//! use i2cdev::linux::{LinuxI2CBus, LinuxI2CError, LinuxI2CMessage};
8085
//!
8186
//! const SLAVE_ADDR: u16 = 0x57;
8287
//!
88+
//! #[cfg(any(target_os = "linux", target_os = "android"))]
8389
//! fn write_read_transaction_using_bus() -> Result<(), LinuxI2CError> {
8490
//! let mut dev = LinuxI2CBus::new("/dev/i2c-1")?;
8591
//!

0 commit comments

Comments
 (0)