diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-02 15:23:02 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-02 15:23:02 +0100 |
commit | 78f41e581af5d93718af68becebe3cbff8fed2d1 (patch) | |
tree | 821cb21c4d47891ec8b2144df9e0a737f614d058 /openpgp/src/types/key_flags.rs | |
parent | 5987c772b2681fd82cfb8c3974a5408f40474f5a (diff) |
openpgp: Make KeyFlags::new polymorphic, improve KeyFlags::default.
Diffstat (limited to 'openpgp/src/types/key_flags.rs')
-rw-r--r-- | openpgp/src/types/key_flags.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/openpgp/src/types/key_flags.rs b/openpgp/src/types/key_flags.rs index 51210c32..6b67288f 100644 --- a/openpgp/src/types/key_flags.rs +++ b/openpgp/src/types/key_flags.rs @@ -18,7 +18,7 @@ pub struct KeyFlags{ impl Default for KeyFlags { fn default() -> Self { - KeyFlags::new(&vec![0]) + KeyFlags::new(&[]) } } @@ -124,7 +124,8 @@ impl BitOr for &KeyFlags { impl KeyFlags { /// Creates a new instance from `bits`. - pub fn new(bits: &[u8]) -> Self { + pub fn new<B: AsRef<[u8]>>(bits: B) -> Self { + let bits = bits.as_ref(); let for_certification = bits.get(0) .map(|x| x & KEY_FLAG_CERTIFY != 0).unwrap_or(false); let for_signing = bits.get(0) |