diff --git a/pgrx/src/datum/from.rs b/pgrx/src/datum/from.rs index 9e53c8ae6..832e492f8 100644 --- a/pgrx/src/datum/from.rs +++ b/pgrx/src/datum/from.rs @@ -195,11 +195,7 @@ impl FromDatum for pg_sys::Oid { if is_null { None } else { - datum - .value() - .try_into() - .ok() - .map(|uint| unsafe { pg_sys::Oid::from_u32_unchecked(uint) }) + datum.value().try_into().ok().map(|uint: u32| pg_sys::Oid::from(uint)) } } } diff --git a/pgrx/src/pgbox.rs b/pgrx/src/pgbox.rs index 139deb573..aa720d041 100644 --- a/pgrx/src/pgbox.rs +++ b/pgrx/src/pgbox.rs @@ -73,7 +73,7 @@ use std::ptr::NonNull; /// use pgrx::prelude::*; /// /// pub fn do_something() { -/// # let example_rel_oid = |i| { unsafe { pg_sys::Oid::from_u32_unchecked(i) } }; +/// # let example_rel_oid = |i| pg_sys::Oid::from(i); /// // open a relation and project it as a pg_sys::Relation /// let relid: pg_sys::Oid = example_rel_oid(42); /// let lockmode = pg_sys::AccessShareLock as i32; diff --git a/pgrx/src/rel.rs b/pgrx/src/rel.rs index 9a9ff0125..2cd2f9c83 100644 --- a/pgrx/src/rel.rs +++ b/pgrx/src/rel.rs @@ -208,7 +208,7 @@ impl PgRelation { /// /// ```rust,no_run /// use pgrx::{PgRelation, pg_sys}; - /// # let example_pg_class_oid = |i| { unsafe { pg_sys::Oid::from_u32_unchecked(i) } }; + /// # let example_pg_class_oid = |i| pg_sys::Oid::from(i); /// let oid = example_pg_class_oid(42); // a valid pg_class "oid" value /// let relation = unsafe { PgRelation::from_pg(pg_sys::RelationIdGetRelation(oid) ) }; /// let tupdesc = relation.tuple_desc(); @@ -309,7 +309,7 @@ impl FromDatum for PgRelation { None } else { Some(PgRelation::with_lock( - unsafe { pg_sys::Oid::from_u32_unchecked(u32::try_from(datum.value()).ok()?) }, + pg_sys::Oid::from(u32::try_from(datum.value()).ok()?), pg_sys::AccessShareLock as pg_sys::LOCKMODE, )) } diff --git a/pgrx/src/tupdesc.rs b/pgrx/src/tupdesc.rs index 9a5398ee9..aabd4daf8 100644 --- a/pgrx/src/tupdesc.rs +++ b/pgrx/src/tupdesc.rs @@ -116,7 +116,7 @@ impl<'a> PgTupleDesc<'a> { /// /// ```rust,no_run /// use pgrx::{pg_sys, PgTupleDesc}; - /// # let example_pg_type_oid = |i| { unsafe { pg_sys::Oid::from_u32_unchecked(i) } }; + /// # let example_pg_type_oid = |i| pg_sys::Oid::from(i); /// let typid = example_pg_type_oid(42); // a valid pg_type Oid /// let typmod = 0; // its corresponding typemod value /// let tupdesc = unsafe { PgTupleDesc::from_pg_is_copy(pg_sys::lookup_rowtype_tupdesc_copy(typid, typmod)) };