Skip to content

Slice 'first' confused#4769

Open
A4-Tacks wants to merge 2 commits into
rust-lang:mainfrom
A4-Tacks:slice-first
Open

Slice 'first' confused#4769
A4-Tacks wants to merge 2 commits into
rust-lang:mainfrom
A4-Tacks:slice-first

Conversation

@A4-Tacks

Copy link
Copy Markdown
Member

In a discussion, due to the translation of first element as 1st element, some people understood it as 1st element of variable a

Then he felt confused about 1st element of variable a should be a[0]

@hkBst hkBst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Your change does not seem to address the issue you mentioned. Second -> 2nd -> element a[2] is the same confusion as First -> 1st -> a[1]...

@A4-Tacks

A4-Tacks commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

The 'first' I mentioned comes from 'by storing a reference to the first element', so changing it to a[2] avoids the problem

@A4-Tacks A4-Tacks requested a review from hkBst July 1, 2026 13:47
@hkBst

hkBst commented Jul 1, 2026

Copy link
Copy Markdown
Member

Ah, I see. Maybe just replace "first element" with "starting element"? Then it doesn't matter what index the example uses... What do you think?

@A4-Tacks

A4-Tacks commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Slice has a .first() method, keeping this term may be more consistent

Moreover, changing 'first' to 'starting' may still lead people to misunderstand 'first of slice' as 'first of original'

@hkBst

hkBst commented Jul 1, 2026

Copy link
Copy Markdown
Member

@A4-Tacks Then perhaps we need to be more explicit and say "its first element" instead of "the first element".

@A4-Tacks

A4-Tacks commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Looks good, I hope it's useful

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

Successfully merging this pull request may close these issues.

2 participants