#Issues implementing a trait correctly

15 messages · Page 1 of 1 (latest)

unborn kayak
#

Just for some background, I'm creating a wrapper over GTK4 that allows the creation of widgets though a Lua config file similar to Elkowar's wacky widgets or Aylurs Gtk Widgets. Currently I've been able to pass widgets around wrapped in a struct that implements mlua::UserData and mlua::FromLua. This struct has a field that contains a gtk::Widget like the one with a gtk::Label I've implemented. Within the setup function I create and render a window that takes a child widget as a parameter to the builder. Currently I'm stuck on the implementation of a generic tsuki::Widget that can be used as the child with more specific types such as tsuki::Label being the actual widget passed. Sorry if the answer is super obvious. This is my first somewhat complicated using Rust.

opal karma
#

A tip for future questions, put the crate/type your working with in the title. Makes it easier to find things for people

opal karma
unborn kayak
#

Yeah

#

Let me check rq

unborn kayak
#

I'm assuming I'd need to implement a trait or enum like tsuki::Widget but I haven't figured out how to without tons of errors

opal karma
#

Hmm, one moment I need an actual computer to review large chunks of code

unborn kayak
#

No worries, thanks for the help btw

#

For clarity's sake, I'm going to implement a tsuki::Button struct similar to the label one, and I'd like to be able to take either when pulling the variable

opal karma
unborn kayak
#

I assume I'd have to write a match statement after

opal karma
#

at some point yeah

unborn kayak
#

I guess that makes sense, thanks