in my rust program, I need to declare a mutable variable called start and assign it the value of a backslash later on.
let mut start = '\';
however, the compiler throws this error:
error[E0762]: unterminated character literal
--> src/main.rs:35:19
|
35 | let mut start = '\';
|
I have already tried using “and "" instead of ” but the error persists. Why is this??
>Solution :
You have to escape the \ like so: '\\' to get a char or like this: "\\" if you want to have a &str
If you later want to edit that variable like the mut suggests you probably want a proper String like this:
String::from("\\")