I'm too noob to understand it all but the way I see it, the core is not about using Some instead of iter::slice but what is inside.
I understand this all is in context of Intel Software Guard Extensions about which I know nothing at all, and "UserRef states that userspace may always write to backing memory at any time, and that even &mut UserRef is not exclusive". So it seems that the design of UserRef is basically against Rust principles ("userspace may always write to backing memory"). So when the iterator is just a wrapper over slice::Iter, the code in next() relies on Rust's principles which don't align with how UserRef is supposed to behave. The proposal is to walk over ptr "manually" and return it (cast to UserRef) instead of constructing new UserRef from what slice::Iter would return in that next().map(|e| UserRef::from_ptr(e)).
But does
+pub struct Iter<'a, T: 'a + UserSafe> {
+ ptr: *const T,
really mean that one can happily cast that ptr to UserRef?
What is PhantomData and how/why using it makes any difference, when it's not being changed during iteration?
Is the UserRefdesign sound or was only a workaround some problem?