mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 07:20:20 +08:00
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
This commit is contained in:
parent
fd2dc5e2e0
commit
40c93504dd
@ -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]()
|
||||
|
6
src/understanding-ownership.md
Normal file
6
src/understanding-ownership.md
Normal file
@ -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.
|
Loading…
Reference in New Issue
Block a user