-
|
Is there a reason why most IntoElement components (e.g. Breadcrumb, Button, etc.) don't implement Clone? |
Beta Was this translation helpful? Give feedback.
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 gpui-component/crates/ui/src/icon.rs Lines 231 to 240 in 7de69d1 |
Beta Was this translation helpful? Give feedback.
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.gpui-component/crates/ui/src/icon.rs
Lines 231 to 240 in 7de69d1