Skip to content

Representation of enums #10

Closed
Closed
@nikomatsakis

Description

@nikomatsakis

Discussion topic about how enums are represented in Rust. Some things to work out:

  • What are the #[repr] options available for enums?
    • RFC 2195 defined the layout of #[repr(C)] enums with payloads.
    • RFC 2363 offers a proposal to permit specifying discriminations
  • When do we currently perform Option<T>-like layout optimizations?
  • When do we guarantee Option<T>-like layout optimizations?
    • For any Option-like enum? What about things like Result<T, ()>?
    • What are the conditions on T? (Obviously, must have some undefined values)
    • the Rustonomicon has some text on this topic
  • Are there important enum variant optimizations we want freedom to do in the future that we might want to keep in mind?
  • Size of empty enums and !: defined to be 0
  • C-like enums: define, what does it say about representation?
    • document the effect of #[repr(C) and friends here

Metadata

Metadata

Assignees

Labels

A-layoutTopic: Related to data structure layout (`#[repr]`)S-writeup-assignedStatus: Ready for a writeup and someone is assigned to it

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions