mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
Constrain cyclic associated types (#2702)
Add bounds such that cyclic associated types are equal to themselves. ``` <T as Connection>::Database as Database>::Connection == T <T as ConnectOptions>::Connection as Connection>::Options == T <T as Row>::Database as Database>::Row == T <T as Column>::Database as Database>::Column == T <T as Value>::Database as Database>::Value == T ```
This commit is contained in:
parent
9ba488c831
commit
0d0dddf1d0
4 changed files with 5 additions and 5 deletions
|
@ -4,7 +4,7 @@ use crate::error::Error;
|
|||
use std::fmt::Debug;
|
||||
|
||||
pub trait Column: 'static + Send + Sync + Debug {
|
||||
type Database: Database;
|
||||
type Database: Database<Column = Self>;
|
||||
|
||||
/// Gets the column ordinal.
|
||||
///
|
||||
|
|
|
@ -11,7 +11,7 @@ use url::Url;
|
|||
|
||||
/// Represents a single database connection.
|
||||
pub trait Connection: Send {
|
||||
type Database: Database;
|
||||
type Database: Database<Connection = Self>;
|
||||
|
||||
type Options: ConnectOptions<Connection = Self>;
|
||||
|
||||
|
@ -184,7 +184,7 @@ impl LogSettings {
|
|||
}
|
||||
|
||||
pub trait ConnectOptions: 'static + Send + Sync + FromStr<Err = Error> + Debug + Clone {
|
||||
type Connection: Connection + ?Sized;
|
||||
type Connection: Connection<Options = Self> + ?Sized;
|
||||
|
||||
/// Parse the `ConnectOptions` from a URL.
|
||||
fn from_url(url: &Url) -> Result<Self, Error>;
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::value::ValueRef;
|
|||
/// [`FromRow`]: crate::row::FromRow
|
||||
/// [`Query::fetch`]: crate::query::Query::fetch
|
||||
pub trait Row: Unpin + Send + Sync + 'static {
|
||||
type Database: Database;
|
||||
type Database: Database<Row = Self>;
|
||||
|
||||
/// Returns `true` if this row has no columns.
|
||||
#[inline]
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::borrow::Cow;
|
|||
|
||||
/// An owned value from the database.
|
||||
pub trait Value {
|
||||
type Database: Database;
|
||||
type Database: Database<Value = Self>;
|
||||
|
||||
/// Get this value as a reference.
|
||||
fn as_ref(&self) -> <Self::Database as Database>::ValueRef<'_>;
|
||||
|
|
Loading…
Reference in a new issue