tresure-chest

This commit is contained in:
Alexander Heldt
2025-11-02 16:11:11 +01:00
parent 64d2de2364
commit 5fb5492306
10 changed files with 261 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
pub type TreasureChest(a) {
TreasureChest(String, a)
}
pub type UnlockResult(a) {
Unlocked(a)
WrongPassword
}
pub fn get_treasure(
chest: TreasureChest(treasure),
password: String,
) -> UnlockResult(treasure) {
case chest {
TreasureChest(pass, a) ->
case pass == password {
False -> WrongPassword
True -> Unlocked(a)
}
}
}