From 40c93504ddc35415b55626f067fd8883cae66ff6 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Tue, 12 Jan 2016 14:35:10 -0500 Subject: [PATCH] Update the TOC for ownership. Here's a rough summary of notes from @aturon and I's discussion about this: Topics: - heap vs stack - pointers - slices - scope/drops - Ownership - confusion around allocating strings vs literals - String::new and String.push - or do we use String::from? - scope/drops - Move vs copy - Borrowing - Rust's take on pointers to entire objects - Memory layout - heap vs stack -- what does it mean to own a String -- what even is a String?? - talk in terms of box and arrow diagrams, rather than address spaces etc - keep a high level of conceptual abstraction - pointers - Slices - Rust's take on *interior* pointers - Niko argues that slices and borrowing from fields of a struct are conceptually related - Sing the praises of slices wrt safety! - We get to address string literals very early! - Sidebar on literals and rodata - Advanced: lifetimes --- src/SUMMARY.md | 6 ++++-- src/understanding-ownership.md | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 src/understanding-ownership.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 08434a8b9..2a22bb8b5 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -16,10 +16,12 @@ - [Control flow with `if`](if.md) - [Loops](loops.md) -- [Ownership & borrowing]() +- [Understanding Ownership](understanding-ownership.md) - [Ownership]() - [References & Borrowing]() - - [Lifetimes]() + - [Memory Layout]() + - [Slices]() + - [Advanced: Lifetimes]() - [Structs](structs.md) - [Method Syntax]() diff --git a/src/understanding-ownership.md b/src/understanding-ownership.md new file mode 100644 index 000000000..2b2eb4332 --- /dev/null +++ b/src/understanding-ownership.md @@ -0,0 +1,6 @@ +# Understanding Ownership + +Now that we’ve got some basic syntax under our belt, it’s time to take a look +at Rust’s most unique feature: ownership. We’ll also talk about several related +features: borrowing, slices, and lifetimes, as well as how Rust lays things out +in memory.