Skip to content

Commit

Permalink
debug trait
Browse files Browse the repository at this point in the history
  • Loading branch information
cmichi committed Nov 26, 2020
1 parent 26bd567 commit c05c0b8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crates/storage/src/collections/smallvec/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const _: () = {

impl<T, const N: usize> SpreadLayout for SmallVec<T, N>
where
T: PackedLayout,
T: PackedLayout + Debug,
{
const FOOTPRINT: u64 = 1 + N as u64;

Expand Down
27 changes: 18 additions & 9 deletions crates/storage/src/lazy/lazy_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,17 +215,26 @@ impl<'a, T> DoubleEndedIterator for EntriesIter<'a, T> {

impl<'a, T> ExactSizeIterator for EntriesIter<'a, T> {}

impl<T, const N: usize> EntryArray<T, N>
use std::convert::TryInto;
impl<T: Debug, const N: usize> EntryArray<T, N>
{
//type Bar = CacheCell<Option<StorageEntry<T>>>;

/// Creates a new entry array cache.
pub fn new() -> Self {
Self {
entries: [(); N].map(|_|Default::default())
//entries: [(); N].map(|_|Default::default())
entries: std::iter::repeat_with(|| Default::default())
.take(N)
//.collect::<Vec<CacheCell<Option<StorageEntry<T>>>>>().try_into().unwrap()
.collect::<Vec<CacheCell<Option<StorageEntry<T>>>>>()
//.into()
.try_into().expect("lal")
}
}
}

impl<T, const N: usize> Default for EntryArray<T, N>
impl<T: Debug, const N: usize> Default for EntryArray<T, N>
{
fn default() -> Self {
Self::new()
Expand Down Expand Up @@ -280,7 +289,7 @@ impl<T, const N: usize> EntryArray<T, N>
}
}

impl<T, const N: usize> LazyArray<T, N>
impl<T: Debug, const N: usize> LazyArray<T, N>
where
T: PackedLayout,
{
Expand Down Expand Up @@ -310,14 +319,14 @@ where
}
}

impl<T, const N: usize> Default for LazyArray<T, N>
impl<T: Debug, const N: usize> Default for LazyArray<T, N>
{
fn default() -> Self {
Self::new()
}
}

impl<T, const N: usize> LazyArray<T, N>
impl<T: Debug, const N: usize> LazyArray<T, N>
{
/// Creates a new empty lazy array.
///
Expand Down Expand Up @@ -380,7 +389,7 @@ impl<T, const N: usize> LazyArray<T, N>

impl<T, const N: usize> SpreadLayout for LazyArray<T, N>
where
T: PackedLayout,
T: PackedLayout + Debug,
{
const FOOTPRINT: u64 = N as u64;

Expand All @@ -407,7 +416,7 @@ where
}
}

impl<T, const N: usize> LazyArray<T, N>
impl<T: Debug, const N: usize> LazyArray<T, N>
{
/// Returns the offset key for the given index if not out of bounds.
pub fn key_at(&self, at: Index) -> Option<Key> {
Expand All @@ -418,7 +427,7 @@ impl<T, const N: usize> LazyArray<T, N>
}
}

impl<T, const N: usize> LazyArray<T, N>
impl<T: Debug, const N: usize> LazyArray<T, N>
where
T: PackedLayout,
{
Expand Down

0 comments on commit c05c0b8

Please sign in to comment.