secure-treasure-chest v2
This commit is contained in:
1 parent
172b59c404
commit
7d1d94c31d
1 file changed
+4
-7
@@ -1,7 +1,7 @@
|
||||
import gleam/string
|
||||
|
||||
pub opaque type TreasureChest(a) {
|
||||
TreasureChest(String, a)
|
||||
TreasureChest(password: String, treasure: a)
|
||||
}
|
||||
|
||||
pub fn create(
|
||||
@@ -18,11 +18,8 @@ pub fn open(
|
||||
chest: TreasureChest(treasure),
|
||||
password: String,
|
||||
) -> Result(treasure, String) {
|
||||
case chest {
|
||||
TreasureChest(pass, treasure) ->
|
||||
case pass == password {
|
||||
False -> Error("Incorrect password")
|
||||
True -> Ok(treasure)
|
||||
}
|
||||
case chest.password == password {
|
||||
False -> Error("Incorrect password")
|
||||
True -> Ok(chest.treasure)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user