git.lucas.co / cce-list
things-to-remember checklist
git clone https://git.lucas.co/cce-list.git

commit0c3131603294dc246d2fe113bd1f7ea0bae768a2
parent96a55053cb
authorLucas Galante <lsgalante12@gmail.com>
date2026-10-07 15:30
refactor: register widgets by reference (UiContext::register_host)

register_widget(id, ptr) took a raw pointer in a safe function; cce-ui is
making it an unsafe fn now that every app registers through
register_host(&mut w), which takes the widget's own id and a live borrow.
Registration loops that existed only to hand the registry raw pointers
(and the unsafe blocks and self_ptr casts around them) are gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

 src/main.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 946b001..3569d2d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -670,10 +670,8 @@ impl Application for ListApp {
         // Register once, at self's final address (the registry stores pointers).
         if !self.widgets_registered {
             self.widgets_registered = true;
-            let (id, ptr) = (self.input_box.id(), self.input_box.as_ptr_mut());
-            self.ui_context.register_widget(id, ptr);
-            let (id, ptr) = (self.switcher.id(), self.switcher.as_ptr_mut());
-            self.ui_context.register_widget(id, ptr);
+            self.ui_context.register_host(&mut self.input_box);
+            self.ui_context.register_host(&mut self.switcher);
         }
 
         let size_changed = self.width != size.width as u32