this post was submitted on 21 Jul 2023
5 points (77.8% liked)

Rust Programming

8427 readers
111 users here now

founded 5 years ago
MODERATORS
 

Hi everybody, I'm new to Rust.

So, I have a struct Panel which contains a data widget which implements the trait Widget I have to implement a function for Panel that uses another function that requires a type that implements Widget.

I tried Box<T>, Rc<T>, Box<dyn Widget, &T, but nothing, always compiler errors.

How can I fix this?

top 2 comments
sorted by: hot top controversial new old
[โ€“] [email protected] 3 points 2 years ago

You need to post the errors. What is the function signature?

[โ€“] [email protected] 1 points 2 years ago

Can you give a code example of what you have tried to do already?