diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-05-25 10:48:29 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-05-25 10:48:29 +0200 |
| commit | ca269b1e797c7d5da4e90ba0bdb06eae7f3dcfd9 (patch) | |
| tree | 95060a247500ecf86f86697ac0c939fca0f192db /compiler/rustc_llvm/llvm-wrapper | |
| parent | c12a36adc6e36a9d177c5bb608f5d29c512b0717 (diff) | |
| parent | 664e8a9ce541f0921af23dc9e48b6386b34e8bcf (diff) | |
| download | rust-ca269b1e797c7d5da4e90ba0bdb06eae7f3dcfd9.tar.gz rust-ca269b1e797c7d5da4e90ba0bdb06eae7f3dcfd9.zip | |
Rollup merge of #97233 - c410-f3r:assert-lib, r=scottmcm
[RFC 2011] Library code
CC https://github.com/rust-lang/rust/pull/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.
```rust
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`
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper')
0 files changed, 0 insertions, 0 deletions
