Add some conversion trait impls by Jules-Bertholet · Pull Request #145504 · rust-lang/rust (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

@Jules-Bertholet

@rustbot

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

needs-fcp

This change is insta-stable, or significant enough to need a team FCP to proceed.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

and removed T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Aug 16, 2025

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jieyouxu

clarfonthey

clarfonthey

@tgross35

Preparing for crater

@bors try

@rustbot label +I-libs-api-nominated
r? libs

@rustbot rustbot added the T-libs

Relevant to the library team, which will review and decide on the PR/issue.

label

Sep 5, 2025

@rust-bors

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request

Sep 5, 2025

@rust-bors

…r=

Add some conversion trait impls

tgross35

Comment on lines 1181 to 1191

impl AsMut<str> for AsciiChar {
#[inline(always)]
fn as_mut(&mut self) -> &mut str {
let ascii_ptr: *mut [Self] = crate::slice::from_mut(self);
let str_ptr = ascii_ptr as *mut str;
// SAFETY: Each ASCII codepoint in UTF-8 is encoded as one single-byte
// code unit having the same value as the ASCII byte.
unsafe { &mut *str_ptr }
}
}

Choose a reason for hiding this comment

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

This could probably be implemented in a new as_mut_str method, similar to as_str

Also, could everything here use #[inline] without the always?

@tgross35 tgross35 added S-waiting-on-team

DEPRECATED: Use the team-based variants `S-waiting-on-t-lang`, `S-waiting-on-t-compiler`, ...

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Sep 5, 2025

@rust-bors

☀️ Try build successful (CI)
Build commit: 0498c15 (0498c157964e0946754e29e57ee9ef4527dc2a42, parent: af00ff2ce62b6617ed19305ae39e135ac71d0b22)

@tgross35

@the8472

@rust-rfcbot

This comment was marked as outdated.

@tgross35

This comment was marked as resolved.

@the8472

This comment was marked as resolved.

@rust-rfcbot

This comment was marked as resolved.

@the8472 the8472 removed the T-libs

Relevant to the library team, which will review and decide on the PR/issue.

label

Oct 21, 2025

@the8472

This comment was marked as resolved.

@rust-rfcbot

Team member @the8472 has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rust-rfcbot

🔔 This is now entering its final comment period, as per the review above. 🔔

@SUPERCILEX

Can we get rid of my transpose function in favor of the from impl? Seems a bit weird to have both.

@clarfonthey

I think that dedicated methods are nice because they make things a little clearer than just into(). We're allowed to have both.

@SUPERCILEX

@rust-rfcbot

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

tgross35

Choose a reason for hiding this comment

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

@rustbot rustbot added the S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

label

Nov 6, 2025

Labels

disposition-merge

This issue / PR is in PFCP or FCP with a disposition to merge it.

finished-final-comment-period

The final comment period is finished for this PR / Issue.

needs-fcp

This change is insta-stable, or significant enough to need a team FCP to proceed.

S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

to-announce

Announce this issue on triage meeting