Memory Thinking For Rust
Memory Thinking For Rust
Dmitry Vostokov
Software Diagnostics Services
OpenTask
2
Memory Thinking for Rust: Slides with Descriptions and Source Code
Illustrations
A CIP catalog record for this book is available from the British Library.
Table of Contents
Table of Contents 3
Preface 15
Introduction 17
Prerequisites 18
Training Goals 19
Warning 20
Training Principles 21
Schedule 22
Training Idea 23
Why Rust? 29
My Genealogy of Rust 31
Thought Process 33
4
Pointer 36
Pointer Dereference 37
Many to One 38
Invalid Pointer 40
Pointer to Pointer 43
Pointers as Entities 47
Unsafe Pointer 49
Invalid Pointer 57
Philosophy of Values 66
Moving Values 69
Copying Values 71
Dropping Values 73
Ownership Tree 75
Partial Drops 81
Restricted Ownership 89
Value Lifetime 91
Owner Lifetime 94
Types of Pointers 97
Arrays 166
Vectors 178
Strings 183
C-Strings 187
Size 203
Alignment 209
Forcing 217
Tuples 219
Structs 222
Newtypes 227
Functions 271
self 319
Pinning 331