Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Boxed owned query parameters w/ impl for From<T>#859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
Closed
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletionspostgres-types/src/lib.rs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1044,6 +1044,23 @@ impl BorrowToSql for &dyn ToSql {
}
}

impl sealed::Sealed for Box<dyn ToSql + Sync> {}

impl BorrowToSql for Box<dyn ToSql + Sync> {
#[inline]
fn borrow_to_sql(&self) -> &dyn ToSql {
self.as_ref()
}
}

impl sealed::Sealed for Box<dyn ToSql + Sync + Send> {}
impl BorrowToSql for Box<dyn ToSql + Sync + Send> {
#[inline]
fn borrow_to_sql(&self) -> &dyn ToSql {
self.as_ref()
}
}

impl sealed::Sealed for &(dyn ToSql + Sync) {}

/// In async contexts it is sometimes necessary to have the additional
Expand All@@ -1068,3 +1085,9 @@ where
self
}
}

impl<'a, T: ToSql + Send + Sync + 'a> From<T> for Box<dyn ToSql + Send + Sync + 'a> {
fn from(to_sql: T) -> Self {
Box::new(to_sql)
}
}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We could also add impl for Sync only, although I'm not sure if/when it would be needed:

Suggested change
}
}
impl<'a,T:ToSql +Sync +'a>From<T>forBox<dynToSql +Sync +'a>{
fn from(to_sql:T) ->Self{
Box::new(to_sql)
}
}


[8]ページ先頭

©2009-2025 Movatter.jp