Status : would love to declare a ` fn do_stuff(doer : impl AbleToDoStuff) -> () {}; ` @rustlang are there any discussions / rfcs on using impl traits within function declaration properties ? :)
-
-
-
Replying to @rustlang
My bad it works indeed ! I vas actually concerned about this use case : `impl Trait` not allowed outside of function and inherent method return types ` let a = Dog {}; let b = Cat {}; let animals: Vec<impl MakesNoise> = vec![a, b]; make_some_noise(animals); `
1 reply 0 retweets 1 like -
Replying to @o0ignition0o @rustlang
https://gist.github.com/o0Ignition0o/73cde984e5cb6559327fd16bff6ccf32 … a full gist would actually be less stupid, sorry ^^
1 reply 0 retweets 0 likes -
Replying to @o0ignition0o @rustlang
Yeah today to put a "list of stuff that implements MakesNoise" into a vec you have to box it, e.g. Vec<Box<MakesNoise>>
2 replies 0 retweets 1 like -
This is still because Cat and Dog can be sized differently (or have an unknown size!), so the only way to vectorize them is to stick their heap pointers in a vec. If there's a way to do this without boxing I'd love to know!
1 reply 0 retweets 2 likes -
Replying to @KevinHoffman @rustlang
It seems legit, I got kinda confused as I read impl trait was on stable 1.26, thought more features were added. The size requirement makes sense though, so I don't think it would be possible without boxing
1 reply 0 retweets 2 likes
Yeah, for collections this can’t work. Glad we got it cleared up though!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.