this post was submitted on 21 Jul 2023
0 points (50.0% liked)

Rust Lang

1 readers
1 users here now

Rules [Developing]

Observe our code of conduct

Constructive criticism only

No endless relitigation

No low-effort content

No memes or image macros

No NSFW Content

founded 1 year ago
MODERATORS
 

crosspostato da: https://lemmy.world/post/1916287

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
[–] Kerfuffle@sh.itjust.works 4 points 1 year ago

It's really not possible to answer your question with the information you provided. Just saying "there's an error" doesn't tell us much.

You need to include actual code and the full error messages. Ideally, create a minimal example in the Rust playground that reproduces the issue and then link it: https://play.rust-lang.org/

[–] AngryClosetMonkey@feddit.ch 1 points 1 year ago

What's the specific error that you are seeing?