changeset 743:0fed350d1778

examples: Remove deprecated std::mem::uninitialized().
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 07 Jan 2020 12:34:11 +0100
parents 0a250ddfae79
children 3687205fe620
files examples/anmrenderer.rs examples/eclrenderer.rs examples/stagerunner.rs examples/stdrenderer.rs
diffstat 4 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/examples/anmrenderer.rs	Tue Jan 07 00:23:15 2020 +0100
+++ b/examples/anmrenderer.rs	Tue Jan 07 12:34:11 2020 +0100
@@ -132,7 +132,10 @@
     let mut anm_runner = AnmRunner::new(anms, script, sprite.clone(), Rc::downgrade(&prng), 0);
 
     assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>());
-    let mut vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() };
+    let mut vertices: [Vertex; 4] = {
+        let data = std::mem::MaybeUninit::uninit();
+        unsafe { data.assume_init() }
+    };
     fill_vertices(sprite.clone(), &mut vertices);
 
     // set the uniform interface to our type so that we can read textures from the shader
--- a/examples/eclrenderer.rs	Tue Jan 07 00:23:15 2020 +0100
+++ b/examples/eclrenderer.rs	Tue Jan 07 12:34:11 2020 +0100
@@ -128,7 +128,10 @@
     let mut ecl_runner = EclRunner::new(&ecl, enemy.clone(), sub);
 
     assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>());
-    let vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() };
+    let vertices: [Vertex; 4] = {
+        let data = std::mem::MaybeUninit::uninit();
+        unsafe { data.assume_init() }
+    };
 
     let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap();
 
--- a/examples/stagerunner.rs	Tue Jan 07 00:23:15 2020 +0100
+++ b/examples/stagerunner.rs	Tue Jan 07 12:34:11 2020 +0100
@@ -128,7 +128,10 @@
     let game = Rc::new(RefCell::new(game));
 
     assert_eq!(std::mem::size_of::<Vertex>(), std::mem::size_of::<FakeVertex>());
-    let vertices: [Vertex; 4] = unsafe { std::mem::uninitialized() };
+    let vertices: [Vertex; 4] = {
+        let data = std::mem::MaybeUninit::uninit();
+        unsafe { data.assume_init() }
+    };
 
     let mut surface = GlfwSurface::new(WindowDim::Windowed(384, 448), "Touhou", WindowOpt::default()).unwrap();
 
--- a/examples/stdrenderer.rs	Tue Jan 07 00:23:15 2020 +0100
+++ b/examples/stdrenderer.rs	Tue Jan 07 12:34:11 2020 +0100
@@ -149,7 +149,10 @@
                 // Create the AnmRunner from the ANM and the sprite.
                 let sprite = Rc::new(RefCell::new(Sprite::with_size(width, height)));
                 let _anm_runner = AnmRunner::new(anms.clone(), quad.anm_script as u8, sprite.clone(), Rc::downgrade(&prng), 0);
-                let mut new_vertices: [Vertex; 6] = unsafe { std::mem::uninitialized() };
+                let mut new_vertices: [Vertex; 6] = {
+                    let data = std::mem::MaybeUninit::uninit();
+                    unsafe { data.assume_init() }
+                };
                 fill_vertices(sprite.clone(), &mut new_vertices, x, y, z);
                 new_vertices[4] = new_vertices[0];
                 new_vertices[5] = new_vertices[2];