Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

() is not the empty type #59

Open
BartMassey opened this issue Apr 11, 2018 · 1 comment
Open

() is not the empty type #59

BartMassey opened this issue Apr 11, 2018 · 1 comment

Comments

@BartMassey
Copy link

In 1-basics: "The () type is the empty type, nada, void, zilch, nothing. Everything in Rust has a value, but sometimes it's just nothing." The type () actually is a type with a single value, (). It is usually referred to as the "unit type", since it is inhabited by just the one value. The empty type, the type inhabited by no values, is !.

This is important, because the unit value is useful in programs:

match v {
    Some(v) => println!("{}", v),
    None => (),
}
@stevedonovan
Copy link
Owner

Yes, that was sloppy writing - it is definitely not nothing. I think I was still confused about void in those days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants