summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-07-03 12:53:25 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-07-18 17:06:52 +0200
commit7b453c91e484d3b61f9bd970d33bca47f0df0398 (patch)
tree870eac7da9c5a5b52479915c4b50886599e490df
parentbe437462e2bdc774d586c396b116b23b7536fd56 (diff)
openpgp: Rework iteration over set bits.
-rw-r--r--openpgp/src/packet/signature/subpacket.rs2
-rw-r--r--openpgp/src/types/bitfield.rs4
-rw-r--r--openpgp/src/types/features.rs2
-rw-r--r--openpgp/src/types/key_flags.rs2
-rw-r--r--openpgp/src/types/server_preferences.rs2
5 files changed, 7 insertions, 5 deletions
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index d189a179..6f341b0e 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -1297,7 +1297,7 @@ impl fmt::Debug for NotationDataFlags {
need_comma = true;
}
- for i in self.0.iter() {
+ for i in self.0.iter_set() {
match i {
NOTATION_DATA_FLAG_HUMAN_READABLE => (),
i => {
diff --git a/openpgp/src/types/bitfield.rs b/openpgp/src/types/bitfield.rs
index ea0c7c21..8f9098e6 100644
--- a/openpgp/src/types/bitfield.rs
+++ b/openpgp/src/types/bitfield.rs
@@ -23,7 +23,9 @@ impl AsMut<[u8]> for Bitfield {
}
impl Bitfield {
- pub fn iter(&self) -> impl Iterator<Item = usize> + Send + Sync + '_
+ /// Returns all bits that are set starting from bit 0, the
+ /// least-significant bit in the left-most byte.
+ pub fn iter_set(&self) -> impl Iterator<Item = usize> + Send + Sync + '_
{
self.raw.iter()
.flat_map(|b| {
diff --git a/openpgp/src/types/features.rs b/openpgp/src/types/features.rs
index 29fb8560..4d5ac748 100644
--- a/openpgp/src/types/features.rs
+++ b/openpgp/src/types/features.rs
@@ -72,7 +72,7 @@ impl fmt::Debug for Features {
}
// Now print any unknown features.
- for i in self.0.iter() {
+ for i in self.0.iter_set() {
match i {
FEATURE_FLAG_MDC => (),
FEATURE_FLAG_AEAD => (),
diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs
index e2948722..cc95ff2e 100644
--- a/openpgp/src/types/key_flags.rs
+++ b/openpgp/src/types/key_flags.rs
@@ -76,7 +76,7 @@ impl fmt::Debug for KeyFlags {
}
let mut need_comma = false;
- for i in self.0.iter() {
+ for i in self.0.iter_set() {
match i {
KEY_FLAG_CERTIFY
| KEY_FLAG_SIGN
diff --git a/openpgp/src/types/server_preferences.rs b/openpgp/src/types/server_preferences.rs
index 6428196f..b3a19fae 100644
--- a/openpgp/src/types/server_preferences.rs
+++ b/openpgp/src/types/server_preferences.rs
@@ -66,7 +66,7 @@ impl fmt::Debug for KeyServerPreferences {
need_comma = true;
}
- for i in self.0.iter() {
+ for i in self.0.iter_set() {
match i {
KEYSERVER_PREFERENCE_NO_MODIFY => (),
i => {