|
|
Log in / Subscribe / Register

Never traits

Never traits

Posted Sep 11, 2026 5:50 UTC (Fri) by tsavola (subscriber, #37605)
In reply to: Never traits by micka
Parent article: Stabilizing Rust's never type

Yes, but with ! that code path is never reached. The compiler could say that it can, because it never has to.


to post comments

Never traits

Posted Sep 11, 2026 6:57 UTC (Fri) by taladar (subscriber, #68407) [Link] (1 responses)

But that is not how traits work in Rust. What you suggest would be true if all traits just had their types appear in parameter position in the methods they implement but traits like Default have them appear only in return type position where you absolutely have to come up with a value if someone calls <! as Default>::default()

Never traits

Posted Sep 11, 2026 7:17 UTC (Fri) by tsavola (subscriber, #37605) [Link]

Okay, I see.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds