3 ms·
> Range<Vec> requires the borrow, so the vastly more common Range<usize> etc. So I have no idea about rust, but in c++ a big feature of templated code is that
by josefx 6y ago
> Range<Vec> requires the borrow, so the vastly more common Range<usize> etc.
So I have no idea about rust, but in c++ a big feature of templated code is that you can make type appropriate specializations, is that not possible in Rust or did its standard library maintainers just sleep on the job?
- sushisource 6y ago"Sleep on the job" might be a bit unfair. Specialization doesn't exist but is in the works.
- akiselev 6y agoIt's been in the works for years and there's no end in sight. IIRC sound specialization might not be possible until some precursor work for GATs is complete. Last I checked (a month or two ago), the specialization feature warning even included a bit about how it can crash the compiler (the crashes were the reason I gave up on specialization two years ago) Edit: Turns out theres been some progress since I used it last! Feature `min_specialization` seems to not be a non-crashing subset of specialization [1] [1] https://github.com/rust-lang/rust/pull/68970 https://github.com/rust-lang/rust/pull/68970
- edflsafoiewq 6y agoRust has specialization but I don't think you can change the signature like that. In C++ of course it's the callee that decides how arguments are passed. But it would also be uncommon in C++ to specialize to pass by value. Generic code normally just passes T by reference, ex. max, push_back. Since this is transparent to the caller in C++ though, you don't have to write the &s.