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: collect_structs_and_enums.rs
    path of file: ./repos/slint/internal/compiler/passes
    
    the code of the file until where you have to start completion: // Copyright Â© SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial

//! Passes that fills the root component used_types.structs

use crate::expression_tree::Expression;
use crate::langtype::Type;
use crate::object_tree::*;
use std::collections::BTreeMap;
use std::rc::Rc;

/// Fill the root_c
    
pub fn collect_structs_and_enums(doc: &Document) {
    let mut hash = BTreeMap::new();

    for (_, exp) in doc.exports.iter() {
        if let Some(ty) = exp.as_ref().right() {
            maybe_collect_object(ty, &mut hash);
        }
    }

    for component in (doc.root_component.used_types.borrow().sub_components.iter())
        .chain(std::iter::once(&doc.root_component))
    {
        collect_types_in_component(component, &mut hash)
    }

    let mut used_types = doc.root_component.used_types.borrow_mut();
    let used_struct_and_enums = &mut used_types.structs_and_enums;
    *used_struct_and_enums = Vec::with_capacity(hash.len());
    while let Some(next) = hash.iter().next() {
        // Here, using BTreeMap::pop_first would be great when it is stable
        let key = next.0.clone();
        sort_types(&mut hash, used_struct_and_enums, &key);
    }
}