Skip to content

How to run a sample example?  #175

Description

@arunpatro

I am unable to execute this test:

use hash_db::Hasher;
use reference_trie::{RefTrieDBMut, RefTrieDB};
use trie_db::DBValue;
use keccak_hasher::KeccakHasher;
use memory_db::*;

fn main() {
    let mut memdb = MemoryDB::<KeccakHasher, HashKey<_>, _>::default();
    let mut root = Default::default();
    RefTrieDBMut::new(&mut memdb, &mut root).insert(b"foo", b"bar").unwrap();
    let t = RefTrieDB::new(&memdb, &root);
    assert!(t.contains(b"foo").unwrap());
    assert_eq!(t.get(b"foo").unwrap().unwrap(), b"bar".to_vec());
}

But I get this error:

 --> src/main.rs:10:19
   |
10 |     RefTrieDBMut::new(&mut memdb, &mut root).insert(b"foo", b"bar").unwrap();
   |                   ^^^ function or associated item not found in `trie_db::triedbmut::TrieDBMut<'_, ExtensionLayout>`

And Indeed trie_db::triedbmut::TrieDBMut doesn't have a new method. Any help?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions