Repository navigation
|
Is there a reason why most IntoElement components (e.g. Breadcrumb, Button, etc.) don't implement Clone? |
Answered by
huacnlee
Nov 17, 2025
Replies: 1 comment
|
This is because of the GPUI IntoElement design. In GPUI, the element that impl Followhing this design, all elements of struct Button {
children: Vec<Div>
}You may see the |
0 replies
Answer selected by
Moulberry
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is because of the GPUI IntoElement design.
In GPUI, the element that impl
IntoElementare useRenderOnce, and you can see therendermethod of this, theselfis designed with will take ownership.Followhing this design, all elements of
IntoElement(We call it Stateless) does not implementClone. Because we couldn't, there may have some not clonable members in it, for example achildrenusedDiv, theDivis not clonable.You may see the
Iconelement, it is anIntoElement, but it is clonable. This just a special one, the clone is very special.https://github.com/longbridge/gpui-component/blob/7de69d1dd134c2ddcf3ca9fa46e7c0b9317ccd45/crates/ui/src…