rust-osdev/volatile

consider removing the lifetime from `VolatilePtr`

kadiwa4 opened this issue · 4 comments

VolatilePtr is used for memory-mapped I/O where lifetimes are not useful. Also, as a volatile counterpart to *-pointers, it would make sense if it didn't have a lifetime either.

It seems it was added in c3d6b9a to make map_mut sound, but that function has been removed again and today's map function can easily be used to map from a 'static to another 'static VolatilePtr.
Does it still serve a purpose?

Personally I also use VolatilePtr in cases where the lifetime is not 'static e.g. the lifetime depends on the lifetime of the mapped memory.

@Freax13 and VolatileRef doesn't work for that case? I will close the issue then

Accesses to a VolatileRef happen through a VolatilePtr returned by VolatileRef::as_ptr, VolatileRef::as_mut_ptr or VolatileRef::into_ptr. All of these functions return a VolatilePtr with a lifetime which is not static if the lifetime of VolatileRef isn't also static. In other words removing, the lifetime from VolatilePtr would also break VolatileRef.

makes sense