How to return an exception in Rust?

Trying to get my first exercise done in Rust, but I don’t know how to throw an exception.

pub fn square(s: u32) → u64 {
if s = 0 || s > 64 {
—I want to throw the exceptions here!—
}
let mut x: u64 = 1;
for _n in 0…(s-1) {
x *= 2;
}
return x;
}

This website is very good, keep it handy while you are learning the language!

1 Like