Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
cmichi committed Nov 26, 2020
1 parent 5cfa303 commit 2555599
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion crates/storage/src/lazy/lazy_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T, const N: usize> EntryArray<T, N>
{
/// Creates a new entry array cache.
pub fn new() -> Self {
let entries =
std::iter::repeat_with(|| Default::default())
.take(N)
.collect::<Vec<CacheCell<Option<StorageEntry<T>>>>>()
.try_into();
let entries = match entries {
Ok(entries) => entries,
Err(_) => unreachable!("f"),
};
Self {
entries: [(); N].map(|_|Default::default())
entries
}
}
}
Expand Down
1 change: 0 additions & 1 deletion crates/storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]

Expand Down

0 comments on commit 2555599

Please sign in to comment.