Skip to content

Commit e37e475

Browse files
author
bitfl0wer
committed
extend uinttype trait
1 parent f7410c0 commit e37e475

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

sqlx-pg-uint/src/lib.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ mod u32;
4343
mod u64;
4444
mod u8;
4545

46+
use std::fmt::Display;
47+
use std::str::FromStr;
48+
4649
pub(crate) use bigdecimal::BigDecimal;
4750
use thiserror::Error;
4851
pub use u128::*;
@@ -73,11 +76,17 @@ mod private {
7376
pub trait Sealed {}
7477
}
7578

79+
impl private::Sealed for u8 {}
80+
impl private::Sealed for u16 {}
81+
impl private::Sealed for u32 {}
82+
impl private::Sealed for u64 {}
83+
impl private::Sealed for u128 {}
84+
7685
/// Helper trait to define the underlying integer type for a given `PgUint` type. Used in the
7786
/// `sqlx-pg-uint-macros` crate to generate the necessary code for the `UIntWrapper` derive.
7887
///
7988
/// Not intended to be implemented by users, nor is it required to be used directly.
80-
pub trait UIntType: private::Sealed {
89+
pub trait UIntType: private::Sealed + Display {
8190
/// The underlying integer type for the `PgUint` type.
82-
type Uint;
91+
type Uint: private::Sealed + FromStr;
8392
}

0 commit comments

Comments
 (0)