From 0e1c1fe1f6efbcc9b74b1f2c15c504a862c49401 Mon Sep 17 00:00:00 2001 From: kennytm Date: Thu, 18 May 2017 22:21:31 +0800 Subject: [PATCH] Fix doctest when feature can be changed. --- .travis.yml | 2 +- src/lib.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d21ee2d..bdd2271 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ install: script: - cargo test --no-default-features - cargo test - - if [ "$TRAVIS_RUST_VERSION" = 'nightly' ]; then cargo bench; fi + - if [ "$TRAVIS_RUST_VERSION" = 'nightly' ]; then cargo bench --features=bench; fi after_success: - cargo install cargo-kcov diff --git a/src/lib.rs b/src/lib.rs index 006a1e8..952253c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,9 +4,11 @@ //! //! ``` //! extern crate qrcode; +//! # #[cfg(feature="image")] //! extern crate image; //! //! use qrcode::QrCode; +//! # #[cfg(feature="image")] //! use image::GrayImage; //! //! fn main() { @@ -14,9 +16,11 @@ //! let code = QrCode::new(b"01234567").unwrap(); //! //! // Render the bits into an image. +//! # #[cfg(feature="image")] //! let image: GrayImage = code.render().to_image(); //! //! // Save the image. +//! # #[cfg(feature="image")] //! image.save("/tmp/qrcode.png").unwrap(); //! } //! ```