Error: no method named `to_string` found for type `std::char::ToUppercase` in the current scope


#1

The following code works fine locally, but the codewars will report the same error as below

CODE:

fn accum(Str: &str) -> String {
let mut cnt = 0;
let Strlen = Str.len();
Str.chars().fold("".to_string(), |res, item| {
cnt += 1;
res + &item.to_uppercase().to_string() + &item.to_string().repeat(cnt-1) + if cnt < Strlen {"-"} else {""}})
}

ERROR:

error: no method named to_string found for type std::char::ToUppercase in the current scope
–> src/lib.rs:6:36
|
6 | res + &item.to_uppercase().to_string() + &item.to_string().repeat(cnt-1) + if cnt < Strlen {"-"} else {""}})
| ^^^^^^^^^
|
= note: the method to_string exists but the following trait bounds were not satisfied: std::char::ToUppercase : std::fmt::Display

error: use of unstable library feature ‘repeat_str’ (see issue #37079)
–> src/lib.rs:6:68
|
6 | res + &item.to_uppercase().to_string() + &item.to_string().repeat(cnt-1) + if cnt < Strlen {"-"} else {""}})
| ^^^^^^

error: aborting due to 2 previous errors


#2

This implementation was added in Rust 1.16; I’m not sure what “codewars” is, but do you know what Rust they’re running?


#3

thank you very much, I know the problem, I was 1.22 version of the local, codewars is 1.15 version.