3 ms·
Yes! If your language allows you to put constraints on those types you can specify what specific types have access to. For example in Rust: fn foo<T: Posit
by bjz_ 9y ago
Yes! If your language allows you to put constraints on those types you can specify what specific types have access to. For example in Rust:
fn foo<T: Positioned>(x: &T) -> Point {
x.position()
}
Note that this doesn't work in languages that use templates for generics, like C++, where templates work more like compile-time duck typing.