summaryrefslogtreecommitdiffstats
path: root/openpgp/src/crypto/symmetric.rs
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-04-07 20:23:44 +0200
committerNora Widdecke <nora@sequoia-pgp.org>2021-04-09 13:13:59 +0200
commit19169b76117db8b1d81f1aafa64a5440d042803d (patch)
treebdd07c05920f6217bd1512e6dc56c1d8fb1da6bf /openpgp/src/crypto/symmetric.rs
parent694680ae3b2192c102f1b9a4d342677545cac629 (diff)
Lint: Use is_empty().
- https://rust-lang.github.io/rust-clippy/master/index.html#len_zero - https://rust-lang.github.io/rust-clippy/master/index.html#comparison_to_empty
Diffstat (limited to 'openpgp/src/crypto/symmetric.rs')
-rw-r--r--openpgp/src/crypto/symmetric.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/openpgp/src/crypto/symmetric.rs b/openpgp/src/crypto/symmetric.rs
index dba529ef..45e9cbd9 100644
--- a/openpgp/src/crypto/symmetric.rs
+++ b/openpgp/src/crypto/symmetric.rs
@@ -107,7 +107,7 @@ impl<R: io::Read> io::Read for Decryptor<R> {
let mut pos = 0;
// 1. Copy any buffered data.
- if self.buffer.len() > 0 {
+ if !self.buffer.is_empty() {
let to_copy = cmp::min(self.buffer.len(), plaintext.len());
&plaintext[..to_copy].copy_from_slice(&self.buffer[..to_copy]);
crate::vec_drain_prefix(&mut self.buffer, to_copy);
@@ -334,7 +334,7 @@ impl<W: io::Write> Encryptor<W> {
/// Finish encryption and write last partial block.
pub fn finish(&mut self) -> Result<W> {
if let Some(mut inner) = self.inner.take() {
- if self.buffer.len() > 0 {
+ if !self.buffer.is_empty() {
unsafe { self.scratch.set_len(self.buffer.len()) }
self.cipher.encrypt(&mut self.scratch, &self.buffer)?;
crate::vec_truncate(&mut self.buffer, 0);
@@ -369,7 +369,7 @@ impl<W: io::Write> io::Write for Encryptor<W> {
let amount = buf.len();
// First, fill the buffer if there is something in it.
- if self.buffer.len() > 0 {
+ if !self.buffer.is_empty() {
let n = cmp::min(buf.len(), self.block_size - self.buffer.len());
self.buffer.extend_from_slice(&buf[..n]);
assert!(self.buffer.len() <= self.block_size);