enhance: 编写更规范的代码
diff --git a/dlqrcode/src/lib.rs b/dlqrcode/src/lib.rs
index deb7c96..12dc747 100644
--- a/dlqrcode/src/lib.rs
+++ b/dlqrcode/src/lib.rs
@@ -39,7 +39,7 @@
totp_seed: Vec<u8>,
}
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct DaliQrData {
pub uid: String,
pub cardno: String,
@@ -165,9 +165,7 @@
for i in 0..qrcode.len() {
if qrcode[i] == v {
if i > j {
- let mut s = Vec::new();
- s.extend_from_slice(&qrcode[j..i]);
- qrdata.push(s);
+ qrdata.push(qrcode[j..i].to_vec());
}
j = i + 1;
if qrdata.len() >= DaliQrData::field_count() {
@@ -176,9 +174,7 @@
}
}
if j < qrcode.len() {
- let mut s = Vec::new();
- s.extend_from_slice(&qrcode[j..]);
- qrdata.push(s);
+ qrdata.push(qrcode[j..].to_vec());
}
Ok(())