Closed
Description
Code
fn convert_c_to_str(c: char) -> &str {
match c {
"A" => "T",
"C" => "G",
"T" => "A",
"G" => "C",
_ => c,
}
}
Current output
error[E0308]: mismatched types
--> src/main.rs:4:9
|
3 | match c {
| - this expression has type `char`
4 | "A" => "T",
| ^^^ expected `char`, found `&str`
error[E0308]: mismatched types
--> src/main.rs:5:9
|
3 | match c {
| - this expression has type `char`
4 | "A" => "T",
5 | "C" => "G",
| ^^^ expected `char`, found `&str`
error[E0308]: mismatched types
--> src/main.rs:6:9
|
3 | match c {
| - this expression has type `char`
...
6 | "T" => "A",
| ^^^ expected `char`, found `&str`
error[E0308]: mismatched types
--> src/main.rs:7:9
|
3 | match c {
| - this expression has type `char`
...
Desired output
...
"Please use single quotes ('_') to generate chars"
Rationale and extra context
For beginners the error message could be a lot simpler. Sometimes they just want to make a char and using single quotes instead of double quotes is not terribly obvious.
Other cases
No response
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: Confusing error or lint; hard to understand for new users.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Relevant to the compiler team, which will review and decide on the PR/issue.