slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.07k stars 573 forks source link

[FEATURE REQUEST] ability to add structs as fields of structs #5414

Closed Areopagitics closed 3 months ago

Areopagitics commented 3 months ago

Would it be possible to do something like this? Thank you! Keep up the good work!

export struct File {
    name: string,
    parent_folder: Folder,
    file_path: string,
    checked: bool,
    file_id: int,
}

export struct Folder {
    name: string,
    file_children: [File],
    folder_path: string,
    checked: bool,
}
kanashimia commented 3 months ago

This is basically two feature requests:

  1. Allow to use structures before they are defined.
  2. Add recursive data structures.

Second one is a duplicate of https://github.com/slint-ui/slint/issues/4218 You can work around this by storing indices to an array instead, like you do in rust.

ogoffart commented 3 months ago

Thanks for filling an issue and thanks @kanashimia for already replying. I'm going to close this as a duplicate of #4218