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

Delegate encode_format to T in &T and Option<T>#928

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

Merged
sfackler merged 3 commits intorust-postgres:masterfromhmac:hmac/encode-format
Aug 4, 2022

Conversation

hmac
Copy link
Contributor

@hmachmac commentedAug 4, 2022
edited
Loading

#836 has been really useful for my use case, and this PR makes some small improvements to it.

I have a custom type (call itT) thatimplsToSql, and I overrideencode_format. However in some situations I'm working with&T orOption<T> and I wantto_sql to use the format that I've specified inencode_format. This change ensures that by delegating toT::encode_format in these cases.

As well as being useful, I believe this fixes a correctness issue, as these types already delegate to their inner type to implementto_sql, so they should do the same forencode_format to avoid emitting, e.g., a text encoding that is tagged as binary.

I've also added[derive(Clone, Copy, Debug)] toFormat, as it's a simple enum and this makes working with it a bit easier.

It's useful to be able to inspect Format values when debugging.
In the ToSql impls for &T and Option<T>, override encode_format todelegate to the impl for T. This ensures that if T overrides thismethod, it also overrides it for &T and Option<T>.
@sfacklersfackler merged commitd650adb intorust-postgres:masterAug 4, 2022
@sfackler
Copy link
Collaborator

Thanks!

@hmachmac deleted the hmac/encode-format branchAugust 4, 2022 23:56
@hmachmac restored the hmac/encode-format branchAugust 4, 2022 23:56
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@hmac@sfackler

[8]ページ先頭

©2009-2025 Movatter.jp