How to remove the first N characters from a string in Rust

1 Answer

0 votes
fn main() {
    let mut str = String::from("abcdefghijklmnop");
    let n = 7;

    // Slice the string starting from index N
    str = str[n..].to_string();

    println!("{}", str);
}



/*
run:

hijklmnop

*/

 



answered Apr 24, 2025 by avibootz
...