Incorporate README example directly into doc test.

This commit is contained in:
kennytm 2017-01-27 01:02:34 +08:00
parent 1d5d6f2883
commit c960c09662
3 changed files with 15 additions and 15 deletions

View file

@ -12,9 +12,12 @@ exclude = [
".travis.yml", ".gitignore", "test-data" ".travis.yml", ".gitignore", "test-data"
] ]
[badges]
travis-ci = { repository = "kennytm/qrcode-rust" }
[dependencies] [dependencies]
num-traits = "0.1.33" num-traits = "0.1.33"
image = { version = "0.12.1", optional = true } image = { version = "0.12.2", optional = true }
[features] [features]
default = ["image"] default = ["image"]

View file

@ -3,7 +3,7 @@ qrcode-rust
[![Build status](https://travis-ci.org/kennytm/qrcode-rust.svg?branch=master)](https://travis-ci.org/kennytm/qrcode-rust) [![Build status](https://travis-ci.org/kennytm/qrcode-rust.svg?branch=master)](https://travis-ci.org/kennytm/qrcode-rust)
[![Coverage Status](https://coveralls.io/repos/github/kennytm/qrcode-rust/badge.svg?branch=coveralls)](https://coveralls.io/github/kennytm/qrcode-rust?branch=coveralls) [![Coverage Status](https://coveralls.io/repos/github/kennytm/qrcode-rust/badge.svg?branch=coveralls)](https://coveralls.io/github/kennytm/qrcode-rust?branch=coveralls)
[![crates.io](http://meritbadge.herokuapp.com/qrcode)](https://crates.io/crates/qrcode) [![crates.io](https://img.shields.io/crates/v/qrcode.svg)](https://crates.io/crates/qrcode)
[![MIT / Apache 2.0](https://img.shields.io/badge/license-MIT%20%2f%20Apache%202.0-blue.svg)](./LICENSE-APACHE.txt) [![MIT / Apache 2.0](https://img.shields.io/badge/license-MIT%20%2f%20Apache%202.0-blue.svg)](./LICENSE-APACHE.txt)
QR code and Micro QR code encoder in Rust. [Documentation](https://docs.rs/qrcode). QR code and Micro QR code encoder in Rust. [Documentation](https://docs.rs/qrcode).

View file

@ -3,26 +3,23 @@
//! This crate provides a QR code and Micro QR code encoder for binary data. //! This crate provides a QR code and Micro QR code encoder for binary data.
//! //!
//! ``` //! ```
//! extern crate image;
//! extern crate qrcode; //! extern crate qrcode;
//! extern crate image;
//! //!
//! use image::GrayImage;
//! use qrcode::QrCode; //! use qrcode::QrCode;
//! use image::GrayImage;
//! //!
//! # fn main() { //! fn main() {
//! // Encode some data into bits.
//! let code = QrCode::new(b"01234567").unwrap();
//! //!
//! let code = QrCode::new(b"Some content here."); //! // Render the bits into an image.
//! match code { //! let image: GrayImage = code.render().to_image();
//! Err(err) => panic!("Failed to encode the QR code: {:?}", err), //!
//! Ok(code) => { //! // Save the image.
//! let image: GrayImage = code.render().min_width(100).to_image(); //! image.save("/tmp/qrcode.png").unwrap();
//! // render `image`...
//! }
//! } //! }
//!
//! # }
//! ``` //! ```
//!
#![cfg_attr(feature="bench", feature(test))] // Unstable libraries #![cfg_attr(feature="bench", feature(test))] // Unstable libraries