pub fn is_balanced(s: &str) -> bool {
    let mut level = 0;
    for ch in s.chars() {
        if ch == '{' {
            level += 1;
        } else if ch == '}' {
            level -= 1;
            if level < 0 {
                return false;
            }
        }
    }
    level == 0
}
/// Returns `true` if the string is balanced.
Returns `true` if the string is balanced.
Returns ` true ` if the string is balanced .
pub fn is_balanced(s: &str) -> bool {
    let mut level = 0;
    for ch in s.chars() {
        if ch == '{' {
            level += 1;
        } else if ch == '}' {
            level -= 1;
            if level < 0 {
                return false;
            }
        }
    }
    level == 0
}
pub fn is_balanced ( s : & str ) -> bool { let mut level = 0 ; for ch in s . chars ( ) { if ch == '{' { level += 1 ; } else if ch == '}' { level -= 1 ; if level < 0 { return false ; } } } level == 0 }
Returns `true` if the string is balanced.
Returns ` true ` if the string is balanced .
s
&str
s
&str