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

Add non_exhaustive to reference. #609

Merged
merged 2 commits into from
Oct 26, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Define inhabited/uninhabited in glossary.
Signed-off-by: David Wood <david@davidtw.co>
  • Loading branch information
davidtwco committed Oct 26, 2019
commit 909b4d15002c94f8bbd252eaba213a48dcf60191
14 changes: 14 additions & 0 deletions src/glossary.md
Original file line number Diff line number Diff line change
@@ -65,6 +65,12 @@ For example, `2 + (3 * 4)` is an expression that returns the value 14.
An [item] that is not a member of an [implementation], such as a *free
function* or a *free const*. Contrast to an [associated item].

### Inhabited

A type is inhabited if it has constructors and therefore can be instantiated. An inhabited type is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is your notion of "has constructors" intended to e.g. take visibility into account? That's the current definition of inhabitedness in the type system but not the abstract machine. You are describing this from the POV of the type system, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, yes..? I just borrowed the explanation from RFC 1216.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. :) Well, this is good.

not "empty" in the sense that there can be values of the type. Opposite of
[Uninhabited](#uninhabited).

### Inherent implementation

An [implementation] that applies to a nominal type, not to a trait-type pair.
@@ -159,6 +165,13 @@ but is not limited to: process termination or corruption; improper, incorrect,
or unintended computation; or platform-specific results.
[More][undefined-behavior].

### Uninhabited

A type is uninhabited if it has no constructors and therefore can never be instantiated. An
uninhabited type is "empty" in the sense that there are no values of the type. The canonical
example of an uninhabited type is the [never type] `!`, or an enum with no variants
`enum Never { }`. Opposite of [Inhabited](#inhabited).

[alignment]: type-layout.md#size-and-alignment
[associated item]: #associated-item
[enums]: items/enumerations.md
@@ -168,6 +181,7 @@ or unintended computation; or platform-specific results.
[inherent implementation]: items/implementations.md#inherent-implementations
[item]: items.md
[method]: items/associated-items.md#methods
[never type]: types/never.md
[object safety]: items/traits.md#object-safety
[structs]: items/structs.md
[trait objects]: types/trait-object.md