redbpf icon indicating copy to clipboard operation
redbpf copied to clipboard

How to turn a map in to specific hashmap?

Open d0u9 opened this issue 3 years ago • 1 comments

let map = Map::from_pin_file("pin_file").unwrap();
let hasmap = HashMap::<u32, u32>::new(&map).unwrap();

The hashmap internally references map, so I can't use hashmap alone without a valid map;

If there has a way like map::into::<HashMap>(), it will be more convenient:

let map = Map::from_pin_file("pin_file").unwrap();
let hasmap: HashMap<u32, u32> = map.try_into().unwrap();

d0u9 avatar Jan 14 '22 04:01 d0u9

Hello @d0u9 It's really nice to see you again. Lucky day!

Thanks for your suggestion :+1: It looks like convenient and neat!

rhdxmr avatar Jan 14 '22 14:01 rhdxmr