Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Additional context on compile-time, template-instantiation-time and run-time is helpful. In Rust, functions can be given generic parameters, which usually require the generic type to implement a certain trait or traits. Within such a function, the generic value can only be used through those traits. This means that a generic function can be type-checked as soon as it is defined. This is in contrast to C++ templates, which are fundamentally duck typed and cannot be checked until instantiated with concrete types. C++ concepts address the same issue. Thus, given no instantiation cases for template(s) will result in no type checking to be done when compiling those template(s). No instantiation may occur in source-code libraries.


Actually that makes sense. Never thought about it that way.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: