You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It warns the user when SplitN is used where n == 1, specifically when used in combination with .next(). When used in this way, splitn is not doing anything and can be omitted altogether. It is more likely that the user meant to only get the first part after splitting, which means n has to be at least 2.
Categories (optional)
Kind: clippy::correctness
What is the advantage of the recommended code over the original code
In the most likely case it will point the user to undesired behaviour, in the other case - where the written code is actually the user's intent - it will make the code more concise.
What it does
It warns the user when SplitN is used where n == 1, specifically when used in combination with .next(). When used in this way, splitn is not doing anything and can be omitted altogether. It is more likely that the user meant to only get the first part after splitting, which means n has to be at least 2.
Categories (optional)
What is the advantage of the recommended code over the original code
In the most likely case it will point the user to undesired behaviour, in the other case - where the written code is actually the user's intent - it will make the code more concise.
Drawbacks
None.
Example
Output:
Could be written as:
Output:
Should (most likely) be written as:
Output:
The text was updated successfully, but these errors were encountered: