You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: _726_number_of_atoms.rs
    path of file: ./repos/rustgym/leetcode/src/d7
    
    the code of the file until where you have to start completion: struct Solution;

use std::collections::BTreeMap;
use std::iter::Peekable;
use std::str::Chars;
use std::vec::IntoIter;

#[derive(Debug)]
enum Tok {
    Num(usize),
    Name(String),
    Op(char),
}

impl Solution {
    fn count_of_atoms(formula: String) -> String {
        let mut it = formula.chars().peekable();
        let tokens = Self::parse_tokens(&mut it);
        let count: BTreeMap<String, usize> = Self::parse(&mut tokens.into_iter().peekable());
        count
            .into_iter()
            .map(|(k, v)| if v > 1 { format!("{}{}", k, v) } else { k })
            .collect()
    }

    fn parse(it: &mut Peekable<IntoIter<Tok>>) -> BTreeMap<String, usize> {
        let mut res: BTreeMap<String, usize> = BTreeMap::new();
        loop {
            match it.peek() {
                Some(Tok::Name(_)) => {
                    if let Some(Tok::Name(s)) = it.next() {
                        let x = if let Some(&Tok::Num(x)) = it.peek() {
                            it.next();
                  
    
    fn parse(it: &mut Peekable<IntoIter<Tok>>) -> BTreeMap<String, usize> {
        let mut res: BTreeMap<String, usize> = BTreeMap::new();
        loop {
            match it.peek() {
                Some(Tok::Name(_)) => {
                    if let Some(Tok::Name(s)) = it.next() {
                        let x = if let Some(&Tok::Num(x)) = it.peek() {
                            it.next();
                            x
                        } else {
                            1
                        };
                        *res.entry(s).or_default() += x;
                    }
                }
                Some(&Tok::Op('(')) => {
                    it.next();
                    let inside = Self::parse(it);
                    it.next();
                    let x = if let Some(&Tok::Num(x)) = it.peek() {
                        it.next();
                        x
                    } else {
                        1
                    };
                    for (k, v) in inside {
                        *res.entry(k).or_default() += v * x;
                    }
                }
                Some(&Tok::Op(')')) | None => {
                    break;
                }
                _ => panic!(),
            }
        }
        res
    }