1

Most of return types are result with a success of a unit tuple, Like In rustic perspective, what is the significance of this?

1 Answer 1

3

It's effectively void - it takes up no bytes, so the only memory used is the enum discriminator and the size of the error side of the enum. It's quite common in rust that you signal success and failure with a Result but if you have nothing to return then you put the empty tuple in there. If you don't need an error then you can use an Option<T> in rust to represent this but there's not a more specialised type that represents something that could error but returns nothing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.