How to get the index of the last occurrence of specified character in a string with Rust

1 Answer

0 votes
fn main() {        
    let s : String = "c c++ csharp java php python".to_string();
    
    println!("{:?}", s.rfind('c'));
    println!("{:?}", s.rfind('a'));
    println!("{:?}", s.rfind('p'));
}



/*
run:
   
Some(6)
Some(16)
Some(22)
   
*/

 



answered Jun 7, 2023 by avibootz
...