sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Implement `Decode`, `Encode` and `Type` for `Box`, `Arc`, `Cow` and `Rc`

Open joeydewaal opened this issue 1 year ago • 4 comments

fixes #3100

Implements Decode, Encode and Type for Box<T>, Arc<T>, Cow<'_,T> and Rc<T>. I left out the Decode impl for Rc<T> because of the Send trait bounds in QueryAs and QueryScalar (which makes it impossible to use Rc).

joeydewaal avatar Jan 09 '25 21:01 joeydewaal

I left out the Decode impl for Rc<T> because of the Send trait bounds in QueryAs and QueryScalar (which makes it impossible to use Rc).

@joeydewaal technically it's still possible to use by getting the Row and then calling get(). Someone's gonna end up asking why it doesn't exist, and justifying that would be more work than just carrying the impl.

We can relax the Send bound on QueryAs/QueryScalar in the future when we get rid of BoxStream in the fetch() method: https://github.com/launchbadge/sqlx/blob/277dd36c7868acb10eae20f50418e273b71c8499/sqlx-core/src/query_as.rs#L111

abonander avatar Feb 28 '25 22:02 abonander

Makes sense, I added the impl for Rc

joeydewaal avatar Mar 03 '25 18:03 joeydewaal

CI should be fixed if you rebase.

abonander avatar Mar 04 '25 22:03 abonander

Right, that should be reflected in the latest changes.

joeydewaal avatar May 20 '25 13:05 joeydewaal