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`
Showing
library/core/src/asserting.rs
0 → 100644
library/core/tests/asserting.rs
0 → 100644
想要评论请 注册 或 登录