intro.ps
mm0.ps
mm.ps
+borrow-mut.ps
+dangling.ps
bck-lifetimes.ps
macros.ps
*.1
SLIDES+= intro
SLIDES+= mm0
SLIDES+= mm
+SLIDES+= borrow-mut
+SLIDES+= dangling
SLIDES+= bck-lifetimes
SLIDES+= macros
bck-lifetimes.ps: bck-err.txt.eps
macros.ps: serde-example.txt.eps macro-rules-example.txt.eps
+borrow-mut.ps: borrow-mut-example.txt.eps
+dangling.ps: dangling.txt.eps
%.eps: %.fig
iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1
--- /dev/null
+fn main() {
+ let mut s = String::from("hello");
+ change(&mut s);
+ println!("{}", s);
+}
+
+fn change(some_string: &mut String) {
+ some_string.push_str(", world");
+}
--- /dev/null
+#FIG 3.2 Produced by xfig version 3.2.6a
+Landscape
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5
+ 0 borrow-mut-example.txt.eps
+ -1170 -2250 10593 -2250 10593 2370 -1170 2370 -1170 -2250
--- /dev/null
+#FIG 3.2 Produced by xfig version 3.2.6a
+Landscape
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5
+ 0 dangling.txt.eps
+ -1170 -2250 10593 -2250 10593 3993 -1170 3993 -1170 -2250
--- /dev/null
+fn main() {
+ let reference_to_nothing = dangle();
+}
+
+fn dangle() -> &String {
+ let s = String::from("hello");
+ &s
+}
+
+
+error[E0106]: missing lifetime specifier
+ --> main.rs:5:16
+ |
+5 | fn dangle() -> &String {
+ | ^ expected lifetime parameter
+ |
+ = help: this function's return type contains a borrowed
+ value, but there is no value for it to be borrowed from
+ = help: consider giving it a 'static lifetime