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
Back a couple weeks ago, I had a program with this code here:
for ch in msg.chars(){if !ch.is_alphabetic(){continue;}let s = caesar_shift(ch, key);
e.push(s);}
This code compiled just fine, where msg is an &str parameter to the function in question.
Now, having duplicated the same code with the same variable as:
for ch in msg.chars(){if !ch.is_alphabetic(){continue;}let p = ch.to_digit(36).unwrap() - 10;// Need to shift down by 10 for range of 0-25let c = alpha.chars().nth(p asusize).unwrap();
e.push(c);}
the compiler presents this error:
src/lib/classical.rs:163:9: 168:10 error: mismatched types:
expected `collections::string::String`,
found `()`
(expected struct `collections::string::String`,
found ()) [E0308]
src/lib/classical.rs:163 for ch in msg.chars() {
src/lib/classical.rs:164 if !ch.is_alphabetic() { continue; }
src/lib/classical.rs:165 let p = ch.to_digit(36).unwrap() - 10; // Need to shift down by 10 for range of 0-25
src/lib/classical.rs:166 let c = alpha.chars().nth(p as usize).unwrap();
src/lib/classical.rs:167 e.push(c);
src/lib/classical.rs:168 }
note: in expansion of for loop expansion
src/lib/classical.rs:163:9: 168:10 note: expansion site
src/lib/classical.rs:163:9: 168:10 help: run `rustc --explain E0308` to see a detailed explanation
Strangely, the old code does not cause the compiler to error out, but I see literally no difference in the new code to speak of that would cause it to not understand what type msg is.
The text was updated successfully, but these errors were encountered:
Back a couple weeks ago, I had a program with this code here:
This code compiled just fine, where msg is an
&str
parameter to the function in question.Now, having duplicated the same code with the same variable as:
the compiler presents this error:
This was using the nightly build in both cases:
Now:
rustc 1.4.0-nightly (f3f23bf9c 2015-08-30)
Then:
rustc 1.4.0-nightly (ab450ef22 2015-08-14)
Strangely, the old code does not cause the compiler to error out, but I see literally no difference in the new code to speak of that would cause it to not understand what type msg is.
The text was updated successfully, but these errors were encountered: