Problem
I find myself confusing the parse and from_str methods quite often. Take for example:
error[E0599]: no function or associated item named `parse` found for struct `connection_string::JdbcString` in the current scope
--> src\connector\mssql.rs:363:55
|
363 | let mut jdbc = connection_string::JdbcString::parse(input)?;
| ^^^^^ function or associated item not found in `connection_string::JdbcString`
parse doesn't exist on JdbcString; from_str does. So the way to fix it would be to write:
// either call `from_str`
let mut jdbc = connection_string::JdbcString::from_str(input)?;
// or flip it and call `parse` on the string
let mut jdbc: connection_string::JdbcString = input.parse()?;
Solution
It'd be great if the diagnostic could detect if parse was called on a type that implements FromStr and suggest to use from_str instead:
error[E0599]: no function or associated item named `parse` found for struct `connection_string::JdbcString` in the current scope
--> src\connector\mssql.rs:363:55
|
363 | let mut jdbc = connection_string::JdbcString::parse(input)?;
| ^^^^^ function or associated item not found in `connection_string::JdbcString`
| |
| help: did you mean to call `connection_string::JdbcString::from_str`?
Problem
I find myself confusing the
parseandfrom_strmethods quite often. Take for example:error[E0599]: no function or associated item named `parse` found for struct `connection_string::JdbcString` in the current scope --> src\connector\mssql.rs:363:55 | 363 | let mut jdbc = connection_string::JdbcString::parse(input)?; | ^^^^^ function or associated item not found in `connection_string::JdbcString`parsedoesn't exist onJdbcString;from_strdoes. So the way to fix it would be to write:Solution
It'd be great if the diagnostic could detect if
parsewas called on a type that implementsFromStrand suggest to usefrom_strinstead:error[E0599]: no function or associated item named `parse` found for struct `connection_string::JdbcString` in the current scope --> src\connector\mssql.rs:363:55 | 363 | let mut jdbc = connection_string::JdbcString::parse(input)?; | ^^^^^ function or associated item not found in `connection_string::JdbcString` | | | help: did you mean to call `connection_string::JdbcString::from_str`?