Skip to content

How to chain different type of objects for a render call #291

Answered by asny
birdistheword96 asked this question in Q&A
Discussion options

You must be logged in to vote

I understand your confusion! As you say Axes and Gm are different types, however they both implement the Object trait and an iterator over Objects is exactly what is needed as the input to the render functions. Unfortunately, Rust does not automatically convert a &Gm or &Axes to a &dyn Object even in this case where it's obviously what is needed. Therefore we need to do that manually so instead of marker_objects.iter().chain(&axes) it should be marker_objects.iter().map(|o| o as &dyn Object).chain(&axes). I hope Rust will implement an automatic conversion in the future, but this is how it works right now.

So you might ask why something like marker_objects[0].into_iter().chain(&marker_obje…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by birdistheword96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants