Rust Nesting
fn nesting(s: &str) -> i64 {
    if s.is_empty() {
        return 1;
    }

    let mut stack = Vec::new();
    for c in s.chars() {
        if c == ')' {
            if stack.pop() != Some('(') {
                return 0;
            }
        } else {
            stack.push(c);
        }
    }

    if stack.is_empty() { 1 } else { 0 }
}

This treats the string like a balance counter: open parentheses add one, closing ones remove one.