secure-treasure-chest v2
This commit is contained in:
@@ -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 {
|
||||
case chest.password == password {
|
||||
False -> Error("Incorrect password")
|
||||
True -> Ok(treasure)
|
||||
}
|
||||
True -> Ok(chest.treasure)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user