[RFC 2011] Library code by c410-f3r · Pull Request #97233 · rust-lang/rust (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation10 Commits1 Checks0 Files changed

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 }})

c410-f3r

CC #96496

Based on https://github.com/dtolnay/case-studies/tree/master/autoref-specialization.

Basically creates two traits with the same method name. One trait is generic over any T and the other is specialized to any T: Printable.

The compiler will then call the corresponding trait method through auto reference.

fn main() { let mut a = Capture::new(); let mut b = Capture::new();

(&Wrapper(&1i32)).try_capture(&mut a); // `try_capture` from `TryCapturePrintable`
(&Wrapper(&vec![1i32])).try_capture(&mut b); // `try_capture` from `TryCaptureGeneric`

assert_eq!(format!("{:?}", a), "1");
assert_eq!(format!("{:?}", b), "N/A");

}

r? @scottmcm

@rustbot rustbot added the T-libs

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

label

May 20, 2022

@rust-highfive

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

c410-f3r

@rust-log-analyzer

This comment has been minimized.

@bors

@c410-f3r

scottmcm

@scottmcm

Thanks for splitting this out! Looks reasonable to me, and since it's internal we can always tweak it later.

@bors r+

@bors

📌 Commit 664e8a9 has been approved by scottmcm

@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

May 25, 2022

@c410-f3r

bors added a commit to rust-lang-ci/rust that referenced this pull request

May 25, 2022

@bors

Rollup of 5 pull requests

Successful merges:

Failed merges:

r? @ghost @rustbot modify labels: rollup

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request

Jun 2, 2022

@Dylan-DPC

[RFC 2011] Basic compiler infrastructure

Splitting rust-lang#96496 into smaller pieces as was done in rust-lang#97233. Hope review will be easier.

This PR practically contains no logic and only serves as a building ground for the actual code that will be placed in a posterior step.

Labels

F-generic_assert

`#![feature(generic_assert)]`

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-libs

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