Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Decode, Encode and Type for Box, Arc, Cow and Rc #3674

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

joeydewaal
Copy link
Contributor

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 joeydewaal changed the title Encode decode Implement Decode, Encode and Type for Box, Arc, Cow and Rc Jan 9, 2025
@abonander
Copy link
Collaborator

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:

) -> BoxStream<'e, Result<Either<DB::QueryResult, O>, Error>>

Copy link
Collaborator

@abonander abonander left a comment

Choose a reason for hiding this comment

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

Previous comment.

@joeydewaal
Copy link
Contributor Author

Makes sense, I added the impl for Rc

@abonander
Copy link
Collaborator

CI should be fixed if you rebase.

impl<'r, DB, T> Decode<'r, DB> for $smart_pointer
where
DB: Database,
T: Decode<'r, DB>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this may actually remove the impls for Box<str> and Box<[u8]> because of the implicit T: Sized bound here.

where
DB: Database,
T: Decode<'r, DB>,
T: ToOwned<Owned = T>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here for Cow<'_, str>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

impl Decode, Encode and Type for smart pointer types like Cow
2 participants