chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 16 May 2019 00:33:13 +0000 (01:33 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 16 May 2019 00:33:13 +0000 (01:33 +0100)
Makefile
dangling-err.txt [new file with mode: 0644]
dangling.fig
dangling.txt
talk.txt

index eeb8936fec18a4947f86e661b759b840147567db..f9a9c2ed0b17ae3b68be70a67012ee3e604627c7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ mm0.ps: mm.fig
 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
+dangling.ps: dangling.txt.eps dangling-err.txt.eps
 
 %.eps:   %.fig
        iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1
diff --git a/dangling-err.txt b/dangling-err.txt
new file mode 100644 (file)
index 0000000..f2142d2
--- /dev/null
@@ -0,0 +1,9 @@
+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
index 30b49207c167d47e85beca6f13fd1753aa110813..cf30050dd32f44bef2d98362335234ec37ceccfe 100644 (file)
@@ -9,4 +9,9 @@ Single
 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
+        -1170 -2250 10593 -2250 10593 1625 -1170 1625 -1170 -2250
+2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5
+       0 dangling-err.txt.eps
+        -1170 2155 10593 2155 10593 5080 -1170 5080 -1170 2155
+2 1 0 2 0 7 50 -1 -1 0.000 0 0 7 0 0 2
+        -1260 1890 10800 1890
index e4b884cecbc1075dffe847eb49e1568007e70b98..b27b01a491263cd26015be8ecb8777a5690d7990 100644 (file)
@@ -6,14 +6,3 @@ 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
index 2e5772d43e37b2601de2f8a128e3518145abaecc..3e7f9bbbeb2edee8044c255ac422c1e94ef38f3f 100644 (file)
--- a/talk.txt
+++ b/talk.txt
@@ -55,6 +55,8 @@ many ways this resembles informal notions of object ownership which
 programmers have typically used in C and C++ to make their code
 comprehensible.
 
+[ Borrowing example slide ]  https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references
+
 But in Rust the ownership is known to the language, and the rules
 surrounding ownership are enforced by the compiler.  When an object
 ceases to have an owner, it is freed.
@@ -62,21 +64,19 @@ ceases to have an owner, it is freed.
 This ownership system is used not only for dynamically allocated
 objects, but for local variables, and statically allocated objects.
 
-[ Borrowing example slide ]  https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references
+[ dangling reference error example  https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#dangling-references ]
 
 To allow an object to be accessed other than through owner, Rust
 formalises the notion of borrowing.  An object can be borrowed by
 writing the ampersand, giving a reference.  The compiler checks that
 the object will outlive the reference.
 
-[ dangling reference error example  https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#dangling-references ]
+[ Borrowing example slide with mut missing ]  ABOVE https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references
 
 Borrows (that is, references) come in two kinds: mutable and
 immutable.  You can have many immutable references at once.  A mutable
 reference permits modification, and provides exclusive access.
 
-[ Borrowing example slide with mut missing ]  ABOVE https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html#mutable-references
-
 That's what the `mut' is doing in that example.  If you leave it out
 the compiler complains.  This is the Rust `borrow checker' that you
 have may have heard about: the part of the compiler which enforces the