singularity

Chapter 19: Advanced Features

Unsafe Rust

Unsafe Superpowers

Dereferencing a Raw Pointer

Calling an Unsafe Function or Method

Accessing or Modifying a Mutable Static Variable

Implementing an Unsafe Trait

Accessing Fields of a Union

When to Use Unsafe Code

Advanced Traits

Associated Types

Default Generic Type Parameters and Operator Overloading

Disambiguating Between Methods with the Same Name

Using Supertraits

Using the Newtype Pattern to Implement External Traits

Advanced Types

Using the Newtype Pattern for Type Safety and Abstraction

Creating Type Synonyms with Type Aliases

The Never Type That Never Returns

Dynamically Sized Types and the Sized Trait

Advanced Functions and Closures

Function Pointers

Returning Closures

Macros

The Difference Between Macros and Functions

Declarative Macros with macro_rules! for General Metaprogramming

Procedural Macros for Generating Code from Attributes

How to Write a Custom derive Macro

Attribute-Like Macros

Function-Like Macros