From 671107870bae5998a936a42c831eda4bd029a88c Mon Sep 17 00:00:00 2001 From: syvb Date: Tue, 12 Nov 2024 14:44:57 -0500 Subject: [PATCH] Allow creating Oid from u32 in a const context --- pgrx-pg-sys/src/submodules/oids.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pgrx-pg-sys/src/submodules/oids.rs b/pgrx-pg-sys/src/submodules/oids.rs index c86129bde5..013b0ec0eb 100644 --- a/pgrx-pg-sys/src/submodules/oids.rs +++ b/pgrx-pg-sys/src/submodules/oids.rs @@ -67,6 +67,13 @@ impl Oid { Oid(id) } + /// Creates an Oid from an arbitrary u32. + /// + /// This is the same as the [`From::from`] implementation, but available in a `const` context. + pub const fn from_u32(id: u32) -> Oid { + Oid(id) + } + /// Gets an Oid from a u32 if it is a valid builtin declared by Postgres pub const fn from_builtin(id: u32) -> Result { match BuiltinOid::from_u32(id) {