dtolnay / linkme

Safe cross-platform linker shenanigans
Apache License 2.0
646 stars 41 forks source link

Add `DistributedSlice::as_ptr_range` #33

Closed nvzqz closed 4 years ago

nvzqz commented 4 years ago

Implemented as a type-level function to prevent accidentally calling slice::as_ptr_range. This is a convention used by smart pointers.

nvzqz commented 4 years ago

By accidentally calling I mean, going through Deref. My concern deals with slice::as_ptr_range not being stable yet, and so the possibility getting confusing errors about requiring nightly because of an accidentally deref.

Both this function and slice::as_ptr_range should return the same result. So maybe it's a better idea to make this a &self method.

A risk in implementing this now is that the as_ptr_range may have a name change (although unlikely). This crate isn't 1.0 yet, so there's still room to rename the method (breaking change) without upsetting the community.

dtolnay commented 4 years ago

I think I would prefer not to add this here and just allow <[_]>::as_ptr_range to stabilize in due course, with it being callable as a method on DistributedSlice via Deref.