diff --git a/content/decks/rust-lifetimes.html b/content/decks/rust-lifetimes.html new file mode 100644 index 0000000..5ee499f --- /dev/null +++ b/content/decks/rust-lifetimes.html @@ -0,0 +1,142 @@ +
+

Lifetimes in Rust

+

It was always there, but now it's explicit

+
+ +
+

Recap: References

+ +
+ +
+

Motivation

+

+	let x;
+	{
+		let y = 5;
+		x = &y;
+	} // uh oh
+	println!("x: {}", x); // hmmm
+	
+

Rust will not compile this code

+
+ +
+

Lifetimes

+ +
+ +
+

Annotation Example

+
+

The borrow checker will use the shortest lifetime

+
+ +
+

Struct Example

+
+
+ + +
+
+

Challenge: Circular references

+
+
+
+

Rc + Refcell

+
+ +
+
+

Vec + Index

+
+ +
+
+

3rd party libraries

+

slotmap: Like a hashmap, but with unique keys

+

typed-arena: Arena allocator. Can only drop the whole arena

+
+ +
+ + +