fn panic
Aborts the current task with a message (§6.6).
Example:
fn pick(i: usize) -> str {
if i > 1 { panic("no such item") }
["a", "b"][i]
}
fn main() io {
let r = scope {
spawn pick(5)
()
}
match r {
Panicked p => print("panic: {p.msg}")
_ => print("fine")
}
}Output
panic: no such item
@intrinsic("panic") pub(api) fn panic(msg: str) -> neverSince. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
msg | str |
Returns
never
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/functions.oxl:112