mm.ps
borrow-mut.ps
dangling.ps
+borrow-nonmut.ps
bck-lifetimes.ps
macros.ps
*.1
SLIDES+= mm
SLIDES+= borrow-mut
SLIDES+= dangling
+SLIDES+= borrow-nonmut
SLIDES+= bck-lifetimes
SLIDES+= macros
macros.ps: serde-example.txt.eps macro-rules-example.txt.eps
borrow-mut.ps: borrow-mut-example.txt.eps
dangling.ps: dangling.txt.eps dangling-err.txt.eps
+borrow-nonmut.ps: borrow-nonmut.txt.eps borrow-nonmut-error.txt.eps
%.eps: %.fig
iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1
--- /dev/null
+error[E0596]: cannot borrow immutable borrowed content
+ `*some_string` as mutable
+ --> error.rs:8:5
+ |
+7 | fn change(some_string: &String) {
+ | ------- use `&mut String` here
+ | to make mutable
+8 | some_string.push_str(", world");
+ | ^^^^^^^^^^^ cannot borrow as mutable
--- /dev/null
+#FIG 3.2 Produced by xfig version 3.2.6a
+Landscape
+Center
+Metric
+A4
+100.00
+Single
+-2
+1200 2
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2
+ -1260 1890 10800 1890
+2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5
+ 0 borrow-nonmut.txt.eps
+ -1170 -2250 8177 -2250 8177 1625 -1170 1625 -1170 -2250
+2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5
+ 0 borrow-nonmut-error.txt.eps
+ -1170 2155 10052 2155 10052 5080 -1170 5080 -1170 2155
--- /dev/null
+fn main() {
+ let s = String::from("hello");
+ change(&s);
+ println!("{}", s);
+}
+
+fn change(some_string: &String) {
+ some_string.push_str(", world");
+}