From 608b4f7a77289720d41c8a4fb9c5d03ef62a8c14 Mon Sep 17 00:00:00 2001 From: Mauro Lacy Date: Thu, 23 Dec 2021 14:13:50 +0100 Subject: [PATCH] Improve migration code examples --- MIGRATING.md | 6 +++--- packages/storage-plus/src/map.rs | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/MIGRATING.md b/MIGRATING.md index b625219fe..ea5b67c8d 100644 --- a/MIGRATING.md +++ b/MIGRATING.md @@ -49,12 +49,12 @@ pub fn migrate(deps: DepsMut, _env: Env, _msg: Empty) -> Result::from(*k)); + signed_int_map.remove(deps.storage, (*k).into()); } // Save in new format - for (k, v) in current.iter() { - signed_int_map_new.save(deps.storage, *k, v)?; + for (k, v) in current.into_iter() { + signed_int_map_new.save(deps.storage, k, &v)?; } // Confirm old map is empty diff --git a/packages/storage-plus/src/map.rs b/packages/storage-plus/src/map.rs index a04015465..94d78bdcd 100644 --- a/packages/storage-plus/src/map.rs +++ b/packages/storage-plus/src/map.rs @@ -685,19 +685,18 @@ mod test { // remove old entries for (k, _) in current.iter() { - SIGNED_ID_OLD.remove(&mut store, IntKeyOld::::from(*k)); + SIGNED_ID_OLD.remove(&mut store, (*k).into()); } // confirm map is empty assert!(SIGNED_ID_OLD .range(&store, None, None, Order::Ascending) - .collect::>>() - .unwrap() - .is_empty()); + .next() + .is_none()); // save in new format - for (k, v) in current.iter() { - SIGNED_ID.save(&mut store, *k, v).unwrap(); + for (k, v) in current.into_iter() { + SIGNED_ID.save(&mut store, k, &v).unwrap(); } // obtain new keys