summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-28 09:59:15 +0300
committerLars Wirzenius <liw@sequoia-pgp.org>2021-09-30 08:31:13 +0300
commit18ab269a0e6967d78df8527679f2479c39650250 (patch)
tree300c052956f3d14422765e0b0c2ddc1e6a13dc8e /net
parent93bf23b79a6ae7bf1a81964a338754d0c16d2ca0 (diff)
Add an is_empty method when len is there
It is customary for Rust data container structures to have both is_empty and len, methods, because is_empty can both more to the point and also faster to implement. Sometimes is_empty makes no sense, as it doesn't for openpgp::types::Curve, which isn't a container structure. Arguably it would be better to rename Curve::len to something like Curve::bits, but as that would change the API, I've opted to tell clippy that not having is_empty in this case is OK. Found by clippy lint len_without_is_empty: https://rust-lang.github.io/rust-clippy/master/index.html#len_without_is_empty
Diffstat (limited to 'net')
-rw-r--r--net/src/updates.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/src/updates.rs b/net/src/updates.rs
index 8313cd62..32b35206 100644
--- a/net/src/updates.rs
+++ b/net/src/updates.rs
@@ -92,6 +92,11 @@ impl Manifest {
self.end
}
+ /// Is the Manifest empty?
+ pub fn is_empty(&self) -> bool {
+ self.prefixes.is_empty()
+ }
+
/// Returns the number of fingerprint prefixes in this Update
/// Manifest.
pub fn len(&self) -> usize {