Cursed Rust
The article "Cursed Rust" humorously explores quirks of the Rust programming language, including the `Copy` and `Clone` traits, if statements as place expressions, naming conventions, and the utility of the `&*` operator.
Read original articleThe article "Cursed Rust" discusses some peculiarities and humorous aspects of the Rust programming language, highlighting features that can lead to unexpected behavior. It begins with the `Copy` and `Clone` traits, illustrating how they can diverge in implementation, as shown in the `OhNo` struct example. The author points out that this divergence is not considered a logic error according to the documentation. Another obscure feature mentioned is that if statements qualify as place expressions, a detail not widely recognized even in the official reference. The article also contrasts the use of "krate" versus "crate_" in naming conventions, questioning how many developers are familiar with the Rust style guide. Additionally, it touches on the use of reference variables with `Cell`, demonstrating how mutable references can be reborrowed. Finally, the author notes the practical utility of the `&*` operator, which, while seemingly trivial, serves important functions in Rust, such as invoking Deref and managing raw pointers. Overall, the piece combines humor with insights into the quirks of Rust, encouraging developers to explore these features more deeply.
- Rust's `Copy` and `Clone` traits can lead to unexpected behavior.
- If statements are considered place expressions, a little-known fact.
- There is a discrepancy in naming conventions between "krate" and "crate_".
- Rust allows reborrowing of mutable references using `Cell`.
- The `&*` operator has practical applications despite its simplicity.
Related
Don't write Rust like it's Java
The author discusses transitioning from Java to Rust, highlighting Rust's type safety, differences in traits and interfaces, complexities of ownership, and the importance of embracing Rust's unique features for effective programming.
From Julia to Rust
The article outlines the author's transition from Julia to Rust, highlighting Rust's memory safety features, design philosophies, and providing resources for learning, while comparing code examples to illustrate syntax differences.
Rust's Ugly Syntax (2023)
The blog post addresses complaints about Rust's syntax, attributing them to misunderstandings of its semantics. It suggests simplifying semantics for readability while maintaining performance and safety features.
Rewriting Rust
The author expresses frustration with Rust's slow progress and unimplemented features, proposing a fork to enhance safety and usability, while raising concerns about supply chain risks and complexity in the language.
Safety Goggles for Alchemists: The Path Towards Safer Transmute
Rust is improving safety in systems programming by addressing risks associated with the unsafe `mem::transmute` function. Community efforts include safer abstractions and the introduction of Project Safe Transmute.
All this is unlike a language i work with in my day job (and hence one would expect that I'd not find surprising), and yet I find so much behavior utterly baffling: https://dev.to/ben/what-is-the-oddest-javascript-behavior-4d...
Related
Don't write Rust like it's Java
The author discusses transitioning from Java to Rust, highlighting Rust's type safety, differences in traits and interfaces, complexities of ownership, and the importance of embracing Rust's unique features for effective programming.
From Julia to Rust
The article outlines the author's transition from Julia to Rust, highlighting Rust's memory safety features, design philosophies, and providing resources for learning, while comparing code examples to illustrate syntax differences.
Rust's Ugly Syntax (2023)
The blog post addresses complaints about Rust's syntax, attributing them to misunderstandings of its semantics. It suggests simplifying semantics for readability while maintaining performance and safety features.
Rewriting Rust
The author expresses frustration with Rust's slow progress and unimplemented features, proposing a fork to enhance safety and usability, while raising concerns about supply chain risks and complexity in the language.
Safety Goggles for Alchemists: The Path Towards Safer Transmute
Rust is improving safety in systems programming by addressing risks associated with the unsafe `mem::transmute` function. Community efforts include safer abstractions and the introduction of Project Safe Transmute.