Skip to content

Commit e558152

Browse files
authored
Moved Sized from FromDatum methods to trait (pgcentralfoundation#1831)
Since all methods of `FromDatum` require `Self` to be `Sized` it makes sense to move the bound to the trait itself.
1 parent c30cae4 commit e558152

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

pgrx/src/datum/from.rs

+6-14
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub enum TryFromDatumError {
3939
///
4040
/// If implementing this, also implement `IntoDatum` for the reverse
4141
/// conversion.
42-
pub trait FromDatum {
42+
pub trait FromDatum: Sized {
4343
/// Should a type OID be fetched when calling `from_datum`?
4444
const GET_TYPOID: bool = false;
4545

@@ -54,10 +54,7 @@ pub trait FromDatum {
5454
///
5555
/// If, however, you're providing an arbitrary datum value, it needs to be considered unsafe
5656
/// and that unsafeness should be propagated through your API.
57-
unsafe fn from_datum(datum: pg_sys::Datum, is_null: bool) -> Option<Self>
58-
where
59-
Self: Sized,
60-
{
57+
unsafe fn from_datum(datum: pg_sys::Datum, is_null: bool) -> Option<Self> {
6158
FromDatum::from_polymorphic_datum(datum, is_null, pg_sys::InvalidOid)
6259
}
6360

@@ -71,9 +68,7 @@ pub trait FromDatum {
7168
datum: pg_sys::Datum,
7269
is_null: bool,
7370
typoid: pg_sys::Oid,
74-
) -> Option<Self>
75-
where
76-
Self: Sized;
71+
) -> Option<Self>;
7772

7873
/// Default implementation switched to the specified memory context and then simply calls
7974
/// `FromDatum::from_datum(...)` from within that context.
@@ -93,10 +88,7 @@ pub trait FromDatum {
9388
datum: pg_sys::Datum,
9489
is_null: bool,
9590
typoid: pg_sys::Oid,
96-
) -> Option<Self>
97-
where
98-
Self: Sized,
99-
{
91+
) -> Option<Self> {
10092
memory_context.switch_to(|_| FromDatum::from_polymorphic_datum(datum, is_null, typoid))
10193
}
10294

@@ -114,7 +106,7 @@ pub trait FromDatum {
114106
type_oid: pg_sys::Oid,
115107
) -> Result<Option<Self>, TryFromDatumError>
116108
where
117-
Self: Sized + IntoDatum,
109+
Self: IntoDatum,
118110
{
119111
if !is_binary_coercible::<Self>(type_oid) {
120112
Err(TryFromDatumError::IncompatibleTypes {
@@ -137,7 +129,7 @@ pub trait FromDatum {
137129
type_oid: pg_sys::Oid,
138130
) -> Result<Option<Self>, TryFromDatumError>
139131
where
140-
Self: Sized + IntoDatum,
132+
Self: IntoDatum,
141133
{
142134
if !is_binary_coercible::<Self>(type_oid) {
143135
Err(TryFromDatumError::IncompatibleTypes {

0 commit comments

Comments
 (0)