We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The ptr_arg lint already warns you when you pass a &String to a function.
&String
For example with this piece of code:
fn print(a: &String) { println!("{:?}", a); } fn main() { let a = "/home/marco".to_string(); print(&a); }
This warning is emitted:
It would be nice if it did the same for PathBuf and Path, because from my understanding, the same principle of String and str applies.
PathBuf
Path
String
str
use std::path::PathBuf; fn print(a: &PathBuf) { println!("{:?}", a); } fn main() { let a: PathBuf = "/home/marco".into(); print(&a); }
Could be written as:
use std::path::{Path, PathBuf}; fn print(a: &Path) { println!("{:?}", a); } fn main() { let a: PathBuf = "/home/marco".into(); print(&a); }
The text was updated successfully, but these errors were encountered:
61a3ee7
Successfully merging a pull request may close this issue.
What it does
The ptr_arg lint already warns you when you pass a
&String
to a function.For example with this piece of code:
This warning is emitted:
It would be nice if it did the same for
PathBuf
andPath
, because from my understanding, the same principle ofString
andstr
applies.Example
Could be written as:
The text was updated successfully, but these errors were encountered: