I'm exploring Functional programming in Rust. I've been reading that language provides an Error
handler with the help of the Result
type.
But when using functions, it might end up in runtime errors. Is there any way to specify that a function might have side effects?
Having this code as a reference:
fn map(self, func: fn(T) -> T) -> TryMonad<T>{
match func(self.success.unwrap()) {
Ok(v) => TryMonad { success: Some(v), failure:None},
Err(error) => TryMonad { success: None, failure:Some(error)},
}
}
Where func
might throw an error.
Shall I consider if that happens it will be an unrecoverable panic
error?