summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/qr_code/src/main.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/examples/qr_code/src/main.rs b/examples/qr_code/src/main.rs
index 6f487e4c..c10c665b 100644
--- a/examples/qr_code/src/main.rs
+++ b/examples/qr_code/src/main.rs
@@ -21,10 +21,7 @@ impl Sandbox for QRGenerator {
type Message = Message;
fn new() -> Self {
- QRGenerator {
- qr_code: qr_code::State::new("").ok(),
- ..Self::default()
- }
+ QRGenerator::default()
}
fn title(&self) -> String {
@@ -36,7 +33,12 @@ impl Sandbox for QRGenerator {
Message::DataChanged(mut data) => {
data.truncate(100);
- self.qr_code = qr_code::State::new(&data).ok();
+ self.qr_code = if data.is_empty() {
+ None
+ } else {
+ qr_code::State::new(&data).ok()
+ };
+
self.data = data;
}
}