rust-lang / rust-lang/reference

Define field, element

Open
#933 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

New Content
Dominant language
Rust
Stars
1.6k
Forks
607
PR merge metrics
PR metrics pending

Description

We use "field" and "element" quite a lot but don't actually define what they are. We need to define them.

We could get rid of the use of "element" (in arrays and tuples) as a separate term and call them fields everywhere. AFAIK, there's no distinction between the two term except where we currently use them.

We may also want to introduce a term "active field" for whether or not the field can be accessed and padding bytes are padding bytes for the containing type. For example of why this would be useful, how do we describe padding of the field/element in A only exists when the value has the A discriminant?

#[repr(u8)]
enum Enum {
    A((u64, u32)),
    B(u128),
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by auditing the existing uses of “field” and “element” in the Rust Reference and compare them with the enum and tuple example in this issue. Decide whether the terms should be unified and whether “active field” is needed to describe conditional access and padding, then document the agreed terminology and examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.