From 18ab269a0e6967d78df8527679f2479c39650250 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 28 Sep 2021 09:59:15 +0300 Subject: 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 --- net/src/updates.rs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'net') 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 { -- cgit v1.2.3