Skip to content

Found single-character string literal pattern RS-P1100 #370

Closed
@philipjonsen

Description

@philipjonsen

Can cause major performance issues.

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

https://github.com/rust-bitcoincore-rpc/blob/master/client/src/client.rs#L212-L212

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions