slint/internal/compiler/passes/collect_libraries.rs
Benny Sjöstrand 0bda0a64eb
Add support for importing Rust types from another crate Slint compilation (#9329)
To implement an external Slint library, the types and components implemented
in the .slint files needs to be exposed through the Rust crate.
A simple example example/app-library is added to demonstrate how to use this feature.

CC #7060
2025-09-16 09:01:44 +02:00

15 lines
590 B
Rust

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
//! This pass fills the root component library_imports
use crate::object_tree::Document;
pub fn collect_libraries(doc: &mut Document) {
doc.imports.iter().for_each(|import| {
if let Some(library_info) = &import.library_info {
library_info.exports.iter().for_each(|export_name| {
doc.library_exports.insert(export_name.to_string(), library_info.clone());
});
}
});
}