Stream: t-lang/wg-unsafe-code-guidelines

Topic: NonNull covariance questions


Lokathor (Jun 07 2019 at 08:44, on Zulip):

I'm trying to wrap a *mut SDL_Palette to make it easier to work with. Now, this is aliased data that never goes across threads. I think that NonNull might fight my use case well. What worries me is the "covariance" thing. The rustonomicon explains Covariance in terms of subtyping, but since this inner pointer itself will never be overwritten by any other value of any other type, I'm not sure if it affects my case. All the data you edit lives on the far side of the pointer and it's not send, so there's methods like this

pub fn set_colors(&self, start: usize, new_colors: &[Color]) -> Result<(), String> { ... }

which should be sound (but also tell me if it's not)

Lokathor (Jun 07 2019 at 08:47, on Zulip):

Complete file: https://github.com/Lokathor/beryllium/blob/22f836228b93da8450c5861b9e9004d3171be6ac/src/palette.rs

Daniel Henry-Mantilla (Jul 21 2019 at 18:02, on Zulip):
Last update: Nov 19 2019 at 17:40UTC