Fixed example code in Rust documentation, related to commits a88f0942af and 3da57e5aa0.

pull/118/head
Project Nayuki 3 years ago
parent 8f9c1be974
commit c8e1b0caed

@ -35,9 +35,11 @@ Examples
-------- --------
extern crate qrcodegen; extern crate qrcodegen;
use qrcodegen::Mask;
use qrcodegen::QrCode; use qrcodegen::QrCode;
use qrcodegen::QrCodeEcc; use qrcodegen::QrCodeEcc;
use qrcodegen::QrSegment; use qrcodegen::QrSegment;
use qrcodegen::Version;
// Simple operation // Simple operation
let qr = QrCode::encode_text("Hello, world!", let qr = QrCode::encode_text("Hello, world!",
@ -47,8 +49,8 @@ Examples
// Manual operation // Manual operation
let chrs: Vec<char> = "3141592653589793238462643383".chars().collect(); let chrs: Vec<char> = "3141592653589793238462643383".chars().collect();
let segs = QrSegment::make_segments(&chrs); let segs = QrSegment::make_segments(&chrs);
let qr = QrCode::encode_segments_advanced( let qr = QrCode::encode_segments_advanced(&segs, QrCodeEcc::High,
&segs, QrCodeEcc::High, 5, 5, Some(Mask::new(2)), false).unwrap(); Version::new(5), Version::new(5), Some(Mask::new(2)), false).unwrap();
for y in 0 .. qr.size() { for y in 0 .. qr.size() {
for x in 0 .. qr.size() { for x in 0 .. qr.size() {
(... paint qr.get_module(x, y) ...) (... paint qr.get_module(x, y) ...)

@ -54,9 +54,11 @@
//! //!
//! ``` //! ```
//! extern crate qrcodegen; //! extern crate qrcodegen;
//! use qrcodegen::Mask;
//! use qrcodegen::QrCode; //! use qrcodegen::QrCode;
//! use qrcodegen::QrCodeEcc; //! use qrcodegen::QrCodeEcc;
//! use qrcodegen::QrSegment; //! use qrcodegen::QrSegment;
//! use qrcodegen::Version;
//! ``` //! ```
//! //!
//! Simple operation: //! Simple operation:
@ -72,8 +74,8 @@
//! ``` //! ```
//! let chrs: Vec<char> = "3141592653589793238462643383".chars().collect(); //! let chrs: Vec<char> = "3141592653589793238462643383".chars().collect();
//! let segs = QrSegment::make_segments(&chrs); //! let segs = QrSegment::make_segments(&chrs);
//! let qr = QrCode::encode_segments_advanced( //! let qr = QrCode::encode_segments_advanced(&segs, QrCodeEcc::High,
//! &segs, QrCodeEcc::High, 5, 5, Some(Mask::new(2)), false).unwrap(); //! Version::new(5), Version::new(5), Some(Mask::new(2)), false).unwrap();
//! for y in 0 .. qr.size() { //! for y in 0 .. qr.size() {
//! for x in 0 .. qr.size() { //! for x in 0 .. qr.size() {
//! (... paint qr.get_module(x, y) ...) //! (... paint qr.get_module(x, y) ...)

Loading…
Cancel
Save