Simplified example Rust code in readme.

This commit is contained in:
Project Nayuki 2018-08-27 02:47:33 +00:00
parent 98d1f0cc91
commit 0860fee6be
2 changed files with 12 additions and 12 deletions

View File

@ -173,18 +173,18 @@ Rust language:
use qrcodegen::QrSegment;
// Simple operation
let qr0 = QrCode::encode_text("Hello, world!",
let qr = QrCode::encode_text("Hello, world!",
QrCodeEcc::Medium).unwrap();
let svg = qr0.to_svg_string(4);
let svg = qr.to_svg_string(4);
// Manual operation
let chrs: Vec<char> = "3141592653589793238462643383".chars().collect();
let segs = QrSegment::make_segments(&chrs);
let qr1 = QrCode::encode_segments_advanced(
let qr = QrCode::encode_segments_advanced(
&segs, QrCodeEcc::High, 5, 5, Some(2), false).unwrap();
for y in 0 .. qr1.size() {
for x in 0 .. qr1.size() {
(... paint qr1.get_module(x, y) ...)
for y in 0 .. qr.size() {
for x in 0 .. qr.size() {
(... paint qr.get_module(x, y) ...)
}
}

View File

@ -39,18 +39,18 @@ Examples
use qrcodegen::QrSegment;
// Simple operation
let qr0 = QrCode::encode_text("Hello, world!",
let qr = QrCode::encode_text("Hello, world!",
QrCodeEcc::Medium).unwrap();
let svg = qr0.to_svg_string(4);
let svg = qr.to_svg_string(4);
// Manual operation
let chrs: Vec<char> = "3141592653589793238462643383".chars().collect();
let segs = QrSegment::make_segments(&chrs);
let qr1 = QrCode::encode_segments_advanced(
let qr = QrCode::encode_segments_advanced(
&segs, QrCodeEcc::High, 5, 5, Some(2), false).unwrap();
for y in 0 .. qr1.size() {
for x in 0 .. qr1.size() {
(... paint qr1.get_module(x, y) ...)
for y in 0 .. qr.size() {
for x in 0 .. qr.size() {
(... paint qr.get_module(x, y) ...)
}
}