7

Github RFC: Add a standard trait for getting many &mut to places by Nokel81...

 3 years ago
source link: https://github.com/rust-lang/rfcs/pull/3100
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

adlerd commented 2 days ago

Is there precedent for GetMutRefs to have an associated type just to support a default implementation? It seems like a different approach should be used here: in particular, I would suggest an unsafe "raw" trait, a safe "user" trait, and an impl<T> GetMutRefs for T where T: GetMutRefsRaw. Then either trait could be chosen to be implemented, and the safe trait would always be used as a bound. (The reason for using this approach as opposed to turning the safe trait into a sealed extension trait is to continue to permit the "safe" default implementation to be replaced in cases where it makes sense to do so.)

Also, is it realistic that there would be an impl GetMutRefs for [T; LENGTH] as opposed to impl GetMutRefs for [T], as the latter is strictly more general? If the array impl is indeed unrealistic then it should not be used as the motivating example in the RFC. (Note that this is separate from the question of the type passed to get_mut_refs, which should indeed be an array.)

Finally, is there sufficient motivation to put this in the standard library instead of a crate? I believe the rust features which started in a crate nursery generally end up with a better design and implementation than otherwise, although this is not a universally held opinion.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK