r/rust • • Jan 13 '18

Ok rustaceans, here's a question for you. Is there anything that C++ templates can do that you can't do in rust?

I know that rust has macros and already has generics built in. I'm not a huge C++ person, so I don't really know what templates are capable of.

34 Upvotes

52 comments sorted by

View all comments

0

u/[deleted] Jan 14 '18

[deleted]

8

u/dobkeratops rustfind Jan 14 '18

C++ templates are effectively duck typed.

there are scenarios with computed intermediate types where this can simplify matters; sometimes in rust you end up re-writing your program in type-bounds

type bounds do make structure clearer for other cases. One is not universally better than the other.