From: Ian Jackson Date: Wed, 15 May 2019 23:56:51 +0000 (+0100) Subject: wip X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=bd1e03be082d24da4db34d976b052fd9d525acb8;p=talk-2019-ghm-rust.git wip --- diff --git a/.gitignore b/.gitignore index 45ebfab..3097f76 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ intro.ps mm0.ps mm.ps +bck-lifetimes.ps *.1 +*.txt.eps slides.pdf slides.ps diff --git a/Makefile b/Makefile index 6622a4d..9970383 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ SLIDES+= intro SLIDES+= mm0 SLIDES+= mm +SLIDES+= bck-lifetimes + SLIDEFILES=$(addsuffix .ps, $(SLIDES)) o= >$@.new && mv -f $@.new $@ @@ -18,6 +20,8 @@ mm0.ps: mm.fig iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1 LC_CTYPE=en_GB fig2dev -L ps -l dummy -z A4 -D-60 <$@.1 $o +bck-lifetimes.ps: bck-err.txt.eps + %.eps: %.fig iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1 # wtf! diff --git a/bck-err.txt b/bck-err.txt new file mode 100644 index 0000000..46c8670 --- /dev/null +++ b/bck-err.txt @@ -0,0 +1,5 @@ +1 | fn longest(x: &str, y: &str) -> &str { + | ^ expected lifetime parameter + | + = help: this function's return type contains a borrowed value, but the +signature does not say whether it is borrowed from `x` or `y` diff --git a/bck-lifetimes.fig b/bck-lifetimes.fig new file mode 100644 index 0000000..f23aabf --- /dev/null +++ b/bck-lifetimes.fig @@ -0,0 +1,29 @@ +#FIG 3.2 Produced by xfig version 3.2.6a +Landscape +Center +Metric +A4 +100.00 +Single +-2 +1200 2 +1 3 0 2 4 7 60 -1 -1 0.000 1 0.0000 2478 3757 611 611 2478 3757 1887 3600 +1 3 0 2 1 7 60 -1 -1 0.000 1 0.0000 4460 3733 385 385 4460 3733 4168 3482 +1 3 0 2 1 7 60 -1 -1 0.000 1 0.0000 7755 3761 385 385 7755 3761 7463 3510 +1 3 0 2 1 7 60 -1 -1 0.000 1 0.0000 6179 4264 385 385 6179 4264 5887 4013 +2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5 + 0 bck-err.txt.eps + -900 -90 11250 -90 11250 1319 -900 1319 -900 -90 +2 1 0 2 0 7 60 -1 -1 0.000 0 0 -1 0 0 2 + -1080 1620 11430 1620 +4 0 0 60 -1 12 30 0.0000 4 390 11400 -900 -1800 fn longest(x: &str, y: &str) -> &str {\001 +4 0 0 60 -1 12 30 0.0000 4 390 11700 -900 -1245 if x.len() > y.len() { x } else { y }\001 +4 0 0 60 -1 12 30 0.0000 4 360 300 -900 -690 }\001 +4 0 0 60 -1 12 30 0.0000 4 360 300 -900 5490 }\001 +4 0 0 60 -1 12 30 0.0000 4 390 11700 -900 5040 if x.len() > y.len() { x } else { y }\001 +4 0 0 60 -1 12 30 0.0000 4 360 7800 990 4365 -> &'a str {\001 +4 0 1 60 -1 1 30 0.0000 4 450 3990 4590 3150 lifetime annotations\001 +4 0 4 60 -1 1 30 0.0000 4 450 1650 270 2160 function\001 +4 0 4 60 -1 1 30 0.0000 4 420 2910 270 2610 parameterised\001 +4 0 4 60 -1 1 30 0.0000 4 450 2085 270 3060 by lifetime\001 +4 0 0 60 -1 12 30 0.0000 4 390 11400 -900 3915 fn longest<'a>(x: &'a str, y: &'a str)\001 diff --git a/intro.fig b/intro.fig index e8a1343..233b1b2 100644 --- a/intro.fig +++ b/intro.fig @@ -7,17 +7,18 @@ A4 Single -2 1200 2 -6 -1350 1125 10800 6300 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 -1350 1125 10800 1125 +2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2 + -1350 5940 10800 5940 +4 0 0 50 -1 2 36 0.0000 4 420 1200 -1350 -1350 Rust\001 4 0 0 50 -1 2 30 0.0000 4 375 2565 -900 2025 Ian Jackson\001 4 0 0 50 -1 2 30 0.0000 4 330 1275 4050 2025 Citrix\001 4 0 0 50 -1 2 30 0.0000 4 435 2115 5850 2025 May 2019\001 -4 0 0 50 -1 2 30 0.0000 4 330 2505 0 3375 Who am I ?\001 -4 0 0 50 -1 2 30 0.0000 4 435 5655 0 4275 curmudgeon and pessimist\001 -4 0 0 50 -1 2 30 0.0000 4 435 6630 0 5175 Perl, C, Tcl, Python, bash, SQL\001 -4 0 0 50 -1 2 30 0.0000 4 435 10320 0 6075 some C++, Haskell, Ocaml, asm, JS, Lisp, Java...\001 --6 -4 0 0 50 -1 2 30 0.0000 4 435 11925 -1350 -450 The most exciting new programming language for years\001 -4 0 0 50 -1 2 36 0.0000 4 420 1200 -1350 -1350 Rust\001 -4 0 0 50 -1 2 30 0.0000 4 435 3105 900 450 (what, really?)\001 +4 0 0 50 -1 2 30 0.0000 4 435 11925 -1350 -630 The most exciting new programming language for years\001 +4 0 0 50 -1 2 30 0.0000 4 435 3105 900 90 (what, really?)\001 +4 0 0 50 -1 2 30 0.0000 4 435 5655 0 3870 curmudgeon and pessimist\001 +4 0 0 50 -1 2 30 0.0000 4 435 5400 0 4590 Perl, C, Tcl, Python, bash\001 +4 0 0 50 -1 2 30 0.0000 4 330 2505 -450 3240 Who am I ?\001 +4 0 0 50 -1 2 30 0.0000 4 435 10320 0 5310 some C++, Haskell, Ocaml, asm, JS, Lisp, Java...\001 +4 0 0 60 -1 0 20 0.0000 4 300 8715 -990 6570 Some examples taken from the Rust Book etc, Apache 2.0 / MIT\001 diff --git a/talk.txt b/talk.txt index a0970be..5440e07 100644 --- a/talk.txt +++ b/talk.txt @@ -205,7 +205,7 @@ E======================================================================E Of course nothing is perfect. I'm very critical by nature, so I often find things to gripe about. -[ borrow checker error ] +[ borrow checker error, lifetime example ] The most obvious difficulty with Rust, if you read the internet, is some's feeling they are constantly fighting the borrow checker.