Should the return value of Rust functions be Result, Option, or return a generic type?

Viewed 214

I'm new to Rust and don't know how to determine whether the return value of a function should be Result or Option, or whether it should return the type as is.

  • Option is used to return a value that may not be available.
  • Result is used to return the result of a process that may fail.
  • In other cases, it returns the type as is.

I'm trying to understand it as above. Is this correct? I would like to know if there are any detailed documents or blogs about coding in Rust.

0 Answers
Related