summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet/mod.rs
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@sequoia-pgp.org>2024-01-24 09:47:01 +0100
committerNeal H. Walfield <neal@sequoia-pgp.org>2024-01-24 10:16:14 +0100
commit7fefbc950a9fc39437a89443dc5eb8ad824a7bb0 (patch)
tree088bff7aeeb7d8d219d6c8374649228bb825a262 /openpgp/src/packet/mod.rs
parent8354a954b2b0c25ee142475de88328cb8f49d270 (diff)
openpgp: Add UserID::from_static_bytes, which is constant.
- Add `UserID::from_static_bytes`, which is equivalent to `UserID::from` for a byte slice, but is a constant function.
Diffstat (limited to 'openpgp/src/packet/mod.rs')
-rw-r--r--openpgp/src/packet/mod.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs
index 3a773a3a..68058053 100644
--- a/openpgp/src/packet/mod.rs
+++ b/openpgp/src/packet/mod.rs
@@ -610,6 +610,18 @@ pub struct Common {
}
assert_send_and_sync!(Common);
+impl Common {
+ /// Returns a default version of `Common`.
+ ///
+ /// This is equivalent to using `Common::from`, but the function
+ /// is constant.
+ pub(crate) const fn new() -> Self {
+ Common {
+ dummy: std::marker::PhantomData
+ }
+ }
+}
+
#[cfg(test)]
impl Arbitrary for Common {
fn arbitrary(_: &mut Gen) -> Self {