Code below is courtesy BHustus. Thanks for an MCVE.
use std::io; use std::io::Stdin; use std::str::FromStr; fn read_line(stdin : &Stdin, line : &mut String) { match stdin.read_linemain(line) { let a: String = OkString::from(_"abcdefgh") => return,; Err(msg) => panic!("Could not read line!let Messageb: {}.", msg), } } fnString parse_t<T= String: FromStr>(s : &strfrom("def") -> T {; matchif s.trim()a.parsecontains(b) { Ok(y) => y, Err(_) => panicprintln!("Could not read from string!""Contained"),; } } fn read_t<T : FromStr>(stdin : &Stdin) -> Telse { let mut line = String::new(); read_lineprintln!(stdin, &mut"Not linecontained"); parse_t(&line) } fn print_can_sort_strings(strs : &mut Vec<(usize, String)>) { strs.sort();} for i in
The compiler error:
Compiling 1playground v0.0.1 strs.len(file:///playground) { let (_,error[E0277]: s_i_minus_1)the =trait strs[ibound -`std::string::String: 1]; let std::ops::FnMut<(_char, s_i) = strs[i]; >` is not //////////////////////////////////////////////////////satisfied --> /src/ THIS STRINGmain.rs:5:CONTAINS CALL GIVES A COMPILER ERROR.10 //////////////////////////////////////////////////////| 5 | if s_ia.contains(s_i_minus_1b) { // Do nothing ... }| else { ^^^^^^^^ the trait println!`std::ops::FnMut<("NO"char,); return; } } >` is not println!("YES"); implemented for (_, s) in strs {`std::string::String` println!("{}", s); | = note: } } fnrequired main()because { of the requirements on letthe stdinimpl =of io `std::stdin(); let n str: u64:pattern::Pattern<'_>` =for read_t(&stdin);`std::string::String` let mut strs = vec![]; for _error: inaborting 0due ..to nprevious {error For more information about this leterror, muttry s`rustc =--explain String::new();E0277`. error: Could read_line(&stdin,not &mutcompile s);`playground`. To learn more, run the command again strs.push((s.len(),with s.trim()--verbose.to_string())); } The print_can_sort_strings(&mutcompiler strs); }error:
The compiler error:
vamsi@vamsi-laptop:~/learn/codeforces/901_1000/problem_988_b$ cargo build Compiling problem_988_b v0.1.0 (file:///home/vamsi/learn/codeforces/901_1000/problem_988_b) error[E0277]: the trait bound `std::string::String: std::ops::FnMut<(char,)>` is not satisfied --> src/main.rs:30:16 | 30 | if s_i.contains(s_i_minus_1) { | ^^^^^^^^ the trait `std::ops::FnMut<(char,)>` is not implemented for `std::string::String` | = note: required because of the requirements on the impl of `std::str::pattern::Pattern<'_>` for `std::string::String` error: aborting due to previous error For more information about this error, try `rustc --explain E0277`. error: Could not compile `problem_988_b`.