5

I'm trying to understand a function similar to the following:

fn some_func(arg1: str, arg2: str) -> error::Result<()>
{
  /// Do some stuff ...
  Ok(())
}

What does the () given to Ok and Result mean in this case? Is this idiomatic or an implementation detail of the codebase?


Update: Compiled the following code block which may serve as a more useful MVCE

fn main() -> Result<(), ()> {
  Ok(())
}
stacksonstacks
  • 8,613
  • 6
  • 28
  • 44
  • Question title may need an update but I'm not sure what else to call it – stacksonstacks Nov 19 '18 at 03:40
  • I'm fairly certain this is an [empty tuple.](https://doc.rust-lang.org/book/second-edition/ch03-02-data-types.html#the-tuple-type) In this case, it looks like an OK result will unwrap to reveal an empty tuple. I'm not sure what the `error::Result<()>` means in this case, though, so I've refrained from adding an answer – Brian Kung Nov 19 '18 at 03:55
  • 2
    Also related: https://stackoverflow.com/questions/24842271/what-is-the-purpose-of-the-unit-type-in-rust – hellow Nov 19 '18 at 07:43

0 Answers0