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

Avoid extra clone in config if possible#1137

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 1 commit intorust-postgres:masterfromnyurik:use-string
Jul 6, 2024

Conversation

nyurik
Copy link
Contributor

Usingimpl Into<String> instead of&str in a fn arg allows both&str andString as parameters - thus if the caller already has a String object that it doesn't need, it can pass it in without extra cloning.

The same might be done with the password, but may require closer look.

Using `impl Into<String>` instead of `&str` in a fn arg allows both `&str` and `String` as parameters - thus if the caller already has a String object that it doesn't need, it can pass it in without extra cloning.The same might be done with the password, but may require closer look.
@sfackler
Copy link
Collaborator

I'm not super opposed to this, but at the same time I'm not sure it'll make a huge difference. What portion of runtime is spent constructing config?

@nyurik
Copy link
ContributorAuthor

@sfackler config specifically is not that big of a deal of course. My concern is that any frequently used code teaches users on how to do things - and in this case, IMO, the API should have only allowedString as the parameter, but because breaking API is not worth it, might as well introduce a backwards compatible solution.

Reasoning:

P.S. community recommended using explicit generic rather thanimpl Into<String> as a param type.

@sfacklersfackler merged commitded5e7d intorust-postgres:masterJul 6, 2024
@nyuriknyurik deleted the use-string branchJuly 7, 2024 12:23
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
@nyurik@sfackler

[8]ページ先頭

©2009-2025 Movatter.jp