DEV Community

Discussion on: Daily Challenge #1 - String Peeler

Collapse
 
werner profile image
Werner Echezuría

Rust

fn trim_string(string: &str) -> &str {
    if string.len() <= 2 {
        panic!("Input string too short");
    }
    &string[1..string.len() - 1]
}