Add result tuple assert
This commit is contained in:
parent
a86b8f4fa4
commit
2fbf82f8ab
|
@ -903,6 +903,13 @@ fn assert! {
|
|||
else panic! string ("Assert failed: ", msg, " with ", value)
|
||||
}
|
||||
|
||||
|
||||
fn assert {
|
||||
"Asserts a condition. Returns a result tuple: `(:ok, value)` if the value is truthy, and `(:err, value)` if it is falsy. Or, give it an error message, and that's what'll be in the error tuple instead."
|
||||
(value) -> if value then (:ok, value) else (:err, value)
|
||||
(msg, value) -> if value then (:ok, value) else (:err, msg)
|
||||
}
|
||||
|
||||
&&& Turtle & other graphics
|
||||
|
||||
& some basic colors
|
||||
|
@ -1282,6 +1289,7 @@ ns prelude {
|
|||
unwrap!
|
||||
unwrap_or
|
||||
assert!
|
||||
assert
|
||||
colors
|
||||
forward!, fd!
|
||||
back!, bk!
|
||||
|
|
Loading…
Reference in New Issue
Block a user