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

Found single-character string literal pattern #335

Open
philipjonsen opened this issue Apr 22, 2024 · 1 comment
Open

Found single-character string literal pattern #335

philipjonsen opened this issue Apr 22, 2024 · 1 comment

Comments

@philipjonsen
Copy link

DESCRIPTION:

Certain str functions, such as .split() and .find() work on patterns that accept both string literals as well as characters. When using such functions, prefer chars over single-character string literals as they are more performant.

Replace the single-character string literal with a char.

BAD PRACTICE
let x = "hello, world";
x.find("o"); // single-character str

RECOMMENDED
let x = "hello, world";
x.find('o'); // use a char instead

rust-bitcoincore-rpc/blob/master/client/src/client.rs#L212-L212

@TheBlueMatt
Copy link
Member

Why open an issue for this rather than just a PR?

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

No branches or pull requests

2 participants