Cocoon Crate - Method lost when passing Structs

This is the rust code
I know dump is missing some args but it isnot recognized by rust at all!
Why is this? And What is the solution?

fn test<M>(container :&mut Cocoon<'_, M>) -> (){
fn main() {
  let mut container = Cocoon::new("passw".as_bytes());
  test(&mut container);

And then I get this

error[E0599]: no method named `dump` found for mutable reference `&mut Cocoon<'_, M>` in the current scope                              
--> src/
21 |   container.dump();
   |             ^^^^ method not found in `&mut Cocoon<'_, M>`

That's because Cocoon<'_, M> does not implement dump. Cocoon<'_, Creation> on the other hand does. A generic M is not specific enough, M must be Creation in order for Cocoon to implement the dump method.

You can amend your function like this:

use cocoon::{Cocoon, Creation};

fn test(container: &mut Cocoon<'_, Creation>) {
    container.dump(b"data".to_vec(), &mut vec![]).unwrap();

to make it compile.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.