Skip to content

Commit

Permalink
Update example to use update_by_ methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lun3x committed Aug 29, 2023
1 parent 956430f commit 26e1f15
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions multi_index_map/examples/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ fn main() {
o1_ref.trader_name, o1_ref
);

let o1_mut_ref = unsafe { map.get_mut_by_order_id(&7).unwrap() };
o1_mut_ref.note = "TestNote".to_string();
println!(
"Changed note of order {o1_mut_ref:?}, to {:?}",
o1_mut_ref.note,
);
let o1_ref = map
.update_by_order_id(&7, |note| {
*note = "TestNote".to_string();
})
.unwrap();
println!("Updated note of order {o1_ref:?}, to {:?}", o1_ref.note,);

let toms_orders = map.remove_by_trader_name(&"Tom".to_string());
assert_eq!(toms_orders.len(), 2);
Expand Down

0 comments on commit 26e1f15

Please sign in to comment.