From f2f590812504850b7e0031312804adf34260a474 Mon Sep 17 00:00:00 2001 From: Xun Li Date: Tue, 21 Dec 2021 22:03:04 -0800 Subject: [PATCH] Use swap_or_fill --- fastx_programmability/framework/Move.toml | 2 +- fastx_programmability/framework/examples/Hero.move | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/fastx_programmability/framework/Move.toml b/fastx_programmability/framework/Move.toml index ae6eb5b8bd8b4..f3c83208c85dd 100644 --- a/fastx_programmability/framework/Move.toml +++ b/fastx_programmability/framework/Move.toml @@ -3,7 +3,7 @@ name = "FastX" version = "0.0.1" [dependencies] -MoveStdlib = { git = "https://github.com/diem/diem.git", subdir="language/move-stdlib", rev = "56ab033cc403b489e891424a629e76f643d4fb6b" } +MoveStdlib = { git = "https://github.com/diem/diem.git", subdir="language/move-stdlib", rev = "5572eae5e35407f10316b473f95cb155a5e8d40b" } [addresses] Std = "0x1" diff --git a/fastx_programmability/framework/examples/Hero.move b/fastx_programmability/framework/examples/Hero.move index fe61011906ed4..bb11c791ecf66 100644 --- a/fastx_programmability/framework/examples/Hero.move +++ b/fastx_programmability/framework/examples/Hero.move @@ -163,14 +163,7 @@ module Examples::Hero { /// Add `new_sword` to the hero's inventory and return the old sword /// (if any) public fun equip_sword(hero: &mut Hero, new_sword: Sword): Option { - // TODO: we should add a Option::swap_opt(&mut Option, T): Option - // that does this to the Move stdlib - if (Option::is_some(&hero.sword)) { - Option::some(Option::swap(&mut hero.sword, new_sword)) - } else { - Option::fill(&mut hero.sword, new_sword); - Option::none() - } + Option::swap_or_fill(&mut hero.sword, new_sword) } /// Disarm the hero by returning their sword.