From 26e1f15d6d9cebbc7961b020c68ce2c29787e99f Mon Sep 17 00:00:00 2001 From: Louis Wyborn Date: Tue, 29 Aug 2023 14:22:45 +0100 Subject: [PATCH] Update example to use update_by_ methods --- multi_index_map/examples/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/multi_index_map/examples/main.rs b/multi_index_map/examples/main.rs index 721509e..d029bb8 100644 --- a/multi_index_map/examples/main.rs +++ b/multi_index_map/examples/main.rs @@ -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);