4 ms·
My comment was not directly about having the ability to mutate or not. It's about that this API design causes close coupling between the API and the internal r
by Matthias247 12y ago
My comment was not directly about having the ability to mutate or not.
It's about that this API design causes close coupling between the API and the internal representation of the API. If you change your internal software structure and the data is stored in another way or you choose the make your library concurrent internally where different parts could mutate the vector while the user might request the same data in parallel then returning the slice would no longer be possible. And so you would have to change your external API and all consumers of the API only because you wanted to change internal things.
But as I said: Depends on the use-case.
- Manishearth 12y ago> If you change your internal software structure and the data is stored in another way or you choose the make your library concurrent internally where different parts could mutate the vector while the user might request the same data in parallel then returning the slice would no longer be possible In that case you wouldn't want to return a slice, because it would be dangerous. The compiler would prevent you from invalidating an API use case. I don't see a problem here.