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 "memset" as doc alias to slice::fill() #79229

Merged
merged 1 commit into from Nov 22, 2020

Conversation

sdroege
Copy link
Contributor

@sdroege sdroege commented Nov 20, 2020

Similar to 53f969d and should make it easier for people coming from C to find this function.

@rust-highfive
Copy link
Collaborator

r? @cramertj

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 20, 2020
@sdroege sdroege changed the title Add "memset" as alias to slice::fill() Add "memset" as doc alias to slice::fill() Nov 20, 2020
@ojeda
Copy link
Contributor

ojeda commented Nov 20, 2020

In general, it can be very different to a memset(). For instance, if the type implements Clone.

@sdroege
Copy link
Contributor Author

sdroege commented Nov 20, 2020

In general, it can be very different to a memset(). For instance, if the type implements Clone.

That's true, but for the cases where you could use memset() it's equivalent (only T=u8 basically, but it behaves equivalent for all Copy types at least)

@ojeda
Copy link
Contributor

ojeda commented Nov 20, 2020

That's true, but for the cases where you could use memset() it's equivalent (only T=u8 basically, but it behaves equivalent for all Copy types at least)

Yeah, although even in those cases, from the perspective of a C programmer, memset() is about setting characters/bytes rather than values. So someone may expect a different result when e.g. filling a bit pattern like fill(0xAA) on T=i32.

I guess the question is whether doc aliases are expected to be used only for "actual aliases" or also for similar/related functions.

@sdroege
Copy link
Contributor Author

sdroege commented Nov 20, 2020

I guess the question is whether doc aliases are expected to be used only for "actual aliases" or also for similar/related functions.

That's something I can't decide, but the same also applies to slice::copy_from_slice() which is only the same as memcpy() for T=u8 too.

In both cases it would've saved me some time in the past if that alias was there when I couldn't remember how that slice function was called again.

@jyn514 jyn514 added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Nov 20, 2020
@sdroege
Copy link
Contributor Author

sdroege commented Nov 21, 2020

#79213 (comment) is doing the same change (and others).

@nagisa
Copy link
Member

nagisa commented Nov 22, 2020

Note that documentation aliases are intended to aid discoverability. It seems to me like its fine to add "you might have success with this" kinds of not-exact-replacements too.

@dtolnay
Copy link
Member

dtolnay commented Nov 22, 2020

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Nov 22, 2020

📌 Commit 7a3b331 has been approved by dtolnay

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 22, 2020
@dtolnay dtolnay assigned dtolnay and unassigned cramertj Nov 22, 2020
@bors
Copy link
Contributor

bors commented Nov 22, 2020

Testing commit 7a3b331 with merge 8ca930a...

@bors
Copy link
Contributor

bors commented Nov 22, 2020

☀️ Test successful - checks-actions
Approved by: dtolnay
Pushing 8ca930a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors label Nov 22, 2020
@bors bors merged commit 8ca930a into rust-lang:master Nov 22, 2020
1 check passed
@rustbot rustbot added this to the 1.50.0 milestone Nov 22, 2020
@sdroege sdroege deleted the slice-fill-memset branch November 22, 2020 08:32
@GuillaumeGomez GuillaumeGomez added A-doc-alias Area: #[doc(alias)] A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-doc-alias Area: #[doc(alias)] A-docs Area: documentation for any part of the project, including the compiler, standard library, and tools merged-by-bors This PR was explicitly merged by bors S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants