when is maybeuninit not a bad idea?
This commit is contained in:
@@ -572,14 +572,11 @@ pub struct SurfaceBufWithImage {
|
|||||||
impl SurfaceBufWithImage {
|
impl SurfaceBufWithImage {
|
||||||
#[allow(invalid_value)]
|
#[allow(invalid_value)]
|
||||||
fn apply_to_surface(self, surface_data: &SurfaceData) {
|
fn apply_to_surface(self, surface_data: &SurfaceData) {
|
||||||
let container = surface_data.data_map.get_or_insert(|| unsafe {
|
if let Some(container) = surface_data.data_map.get::<SurfaceBufWithImageContainer>() {
|
||||||
SurfaceBufWithImageContainer {
|
container.inner.replace(self);
|
||||||
// safe because we're replacing right after
|
} else {
|
||||||
inner: RefCell::new(MaybeUninit::uninit().assume_init()),
|
surface_data.data_map.insert_if_missing(|| self);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
container.inner.replace(self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_from_surface(surface_data: &SurfaceData) -> Option<Self> {
|
pub fn get_from_surface(surface_data: &SurfaceData) -> Option<Self> {
|
||||||
|
|||||||
Reference in New Issue
Block a user