From 2555599bc9e8b7a14cfe0663af5e82730c4ee244 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Thu, 26 Nov 2020 23:05:48 +0100 Subject: [PATCH] wip --- crates/storage/src/lazy/lazy_array.rs | 12 +++++++++++- crates/storage/src/lib.rs | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/storage/src/lazy/lazy_array.rs b/crates/storage/src/lazy/lazy_array.rs index 3464300dfa5..27ed2b9f4e7 100644 --- a/crates/storage/src/lazy/lazy_array.rs +++ b/crates/storage/src/lazy/lazy_array.rs @@ -215,12 +215,22 @@ impl<'a, T> DoubleEndedIterator for EntriesIter<'a, T> { impl<'a, T> ExactSizeIterator for EntriesIter<'a, T> {} +use std::convert::TryInto; impl EntryArray { /// Creates a new entry array cache. pub fn new() -> Self { + let entries = + std::iter::repeat_with(|| Default::default()) + .take(N) + .collect::>>>>() + .try_into(); + let entries = match entries { + Ok(entries) => entries, + Err(_) => unreachable!("f"), + }; Self { - entries: [(); N].map(|_|Default::default()) + entries } } } diff --git a/crates/storage/src/lib.rs b/crates/storage/src/lib.rs index 91357473d98..62d93313c14 100644 --- a/crates/storage/src/lib.rs +++ b/crates/storage/src/lib.rs @@ -20,7 +20,6 @@ //! FFI to interface with SRML contracts and a primitive blockchain //! emulator for simple off-chain testing. -#![feature(array_map)] #![feature(array_methods)] #![feature(min_const_generics)]