qrcode-rust/src/bin/qrencode.rs
2015-04-26 23:47:27 +08:00

24 lines
556 B
Rust
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extern crate qrcode;
use std::env;
const SPACE: char = ' '; //' ';
pub fn main() {
let arg = env::args().nth(1).unwrap();
let code = qrcode::QrCode::new(arg.as_bytes()).unwrap();
print!("\n\n\n\n\n{}{}{}{}{}", SPACE, SPACE, SPACE, SPACE, SPACE);
for y in 0 .. code.width() {
for x in 0 .. code.width() {
let block = if code[(x, y)] { '█' } else { SPACE };
print!("{}{}", block, block);
}
print!("\n{}{}{}{}{}", SPACE, SPACE, SPACE, SPACE, SPACE);
}
println!("\n\n\n\n");
}