From 523caa99c59e9239dbbed4f1d2308d5c512772db Mon Sep 17 00:00:00 2001 From: Dorota Czaplejewicz Date: Sat, 3 Oct 2020 13:11:17 +0000 Subject: [PATCH] build: Avoid MaybeUninit on older Debian --- Cargo.toml.in | 1 + meson.build | 2 +- src/keyboard.rs | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Cargo.toml.in b/Cargo.toml.in index 887bca26..6ec4c047 100644 --- a/Cargo.toml.in +++ b/Cargo.toml.in @@ -19,6 +19,7 @@ path = "@path@/examples/test_layout.rs" [features] gio_v0_5 = [] gtk_v0_5 = [] +rustc_less_1_36 = [] # Dependencies which don't change based on build flags [dependencies.cairo-sys-rs] diff --git a/meson.build b/meson.build index d8e0e1bb..52432a22 100644 --- a/meson.build +++ b/meson.build @@ -83,7 +83,7 @@ cargo_toml_base = configure_file( cargo_deps = files('Cargo.deps') if get_option('legacy') == true - cargo_build_flags += ['--features', 'gtk_v0_5,gio_v0_5'] + cargo_build_flags += ['--features', 'gtk_v0_5,gio_v0_5,rustc_less_1_36'] cargo_deps = files('Cargo.deps.legacy') endif diff --git a/src/keyboard.rs b/src/keyboard.rs index 1801215b..da650c55 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -143,7 +143,11 @@ fn single_key_map_new() -> SingleKeyMap { unsafe { // Inspired by // https://www.reddit.com/r/rust/comments/5n7bh1/how_to_create_an_array_of_a_type_with_clone_but/ + #[cfg(feature = "rustc_less_1_36")] + let mut array: SingleKeyMap = mem::uninitialized(); + #[cfg(not(feature = "rustc_less_1_36"))] let mut array: SingleKeyMap = mem::MaybeUninit::uninit().assume_init(); + for element in array.iter_mut() { ptr::write(element, None); }