mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 02:39:28 +00:00
rust: Simplify item_tree() method by making the tree const
This commit is contained in:
parent
cd932d8cf9
commit
0c952ddee7
1 changed files with 2 additions and 6 deletions
|
@ -1022,12 +1022,8 @@ fn generate_item_tree(
|
|||
}
|
||||
|
||||
fn item_tree() -> &'static [slint::re_exports::ItemTreeNode] {
|
||||
use slint::re_exports::*;
|
||||
// FIXME: ideally this should be a const, but we can't because of the pointer to the vtable
|
||||
static ITEM_TREE : slint::re_exports::OnceBox<
|
||||
[slint::re_exports::ItemTreeNode; #item_tree_array_len]
|
||||
> = slint::re_exports::OnceBox::new();
|
||||
&*ITEM_TREE.get_or_init(|| Box::new([#(#item_tree_array),*]))
|
||||
const ITEM_TREE : [slint::re_exports::ItemTreeNode; #item_tree_array_len] = [#(#item_tree_array),*];
|
||||
&ITEM_TREE
|
||||
}
|
||||
|
||||
fn item_array() -> &'static [vtable::VOffset<Self, ItemVTable, vtable::AllowPin>] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue