If I define a function:
fn f() -> Result<(), E> { // How to return Ok()? }
How can I return the Ok in std::result with the unit type ()?
Ok
std::result
()
The only value of type () is (), so just put that inside the Ok constructor:
fn f() -> Result<(), E> { Ok(()) }
Use Ok(()) as in
Ok(())
Copyright © 2021 Jogjafile Inc.
The only value of type
()
is()
, so just put that inside theOk
constructor: