Borrowing issues with attempted caching

后端 未结 2 1812
南旧
南旧 2021-01-12 02:23

The following code snippet does the same things in 3 ways.

use std::collections::HashMap;

struct Foo {
    cache: HashMap,
}

impl Foo         


        
2条回答
  •  不知归路
    2021-01-12 03:06

    You could try to add &mut on self on show_impl as in

    ...
    fn show_impl(&self, what: &String)  
    ...
    

    So it won't get mixed.

提交回复
热议问题