Open danakj opened 1 year ago
AsRef being singular and AsSlice being plural. Need Mut siblings as well.
Many things can produce a ref/slice without being a ref/slice. Vec is a Slice, has Slice methods. But is a string? Is an unordered map?
But what if you want to receive anything that can give a ref/slice?
Rust has AsRef, but omits AsSlice though many types have .as_slice() which means the caller must do the production.
We could have fn(AsSlice const auto& s) { s.as_slice()…. }
https://youtu.be/Tz5drzXREW0 talks about this desire to write generic code over slice-able things.
AsRef being singular and AsSlice being plural. Need Mut siblings as well.
Many things can produce a ref/slice without being a ref/slice. Vec is a Slice, has Slice methods. But is a string? Is an unordered map?
But what if you want to receive anything that can give a ref/slice?
Rust has AsRef, but omits AsSlice though many types have .as_slice() which means the caller must do the production.
We could have fn(AsSlice const auto& s) { s.as_slice()…. }
https://youtu.be/Tz5drzXREW0 talks about this desire to write generic code over slice-able things.