I'm at the point of struggling with this bug where I can't tell if it's a bug with #Rust or not, but Rust Playground has the error

expected TraitTwo
found TraitTwo


which seems.. nonsensical.

@Eden I gave TraitTwo an explicit lifetime, which still doesn't compile but I think may illuminate that error message a little bit more:

expected TraitTwo<'_>
found TraitTwo<'a>

@balrogboogie so I think it's to do with callee and caller lifetimes, which fits with that information, but I think Rust could be a lot clearer what it should be

@Eden @balrogboogie Please submit a bug! The compiler people are super interested in improving error messages.

@federicomena @balrogboogie will do, been trying to figure out if I was just being silly first!

@Eden @balrogboogie maybe this code is a reduction of a larger problem... but why do you need something like get_ref() if you already have &self?

@federicomena @balrogboogie It's so you can implement it for a non DataObject, but still guarantee get_ref will return a DataObject when used.

Was just using it when another trait was calling get_ref and I wanted to make it clearer what it'd get back

@Eden @balrogboogie hmmm, are you implementing up/downcasting or something like that?

@federicomena @balrogboogie I'm not, no. Honestly I think at this point I should've moved to using a generic function instead of traits that sit upon a single generic struct

@federicomena @balrogboogie it turns out only some of it! Can't get it working with the full trait yet, but I'm trying different lifetimes..

Regístrate para participar en la conversación

La red social del futuro: ¡Sin anuncios, sin vigilancia corporativa, diseño ético, y descentralización! ¡Sé dueño de tu información con Mastodon!