From: Ian Jackson Date: Thu, 16 May 2019 00:06:24 +0000 (+0100) Subject: wip X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=af31b4a05d5d7c0bab021ab341ae062a988876f5;p=talk-2019-ghm-rust.git wip --- diff --git a/.gitignore b/.gitignore index 3097f76..61f2093 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ intro.ps mm0.ps mm.ps bck-lifetimes.ps +macros.ps *.1 *.txt.eps slides.pdf diff --git a/Makefile b/Makefile index 9970383..07b1dcf 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ SLIDES+= mm0 SLIDES+= mm SLIDES+= bck-lifetimes +SLIDES+= macros SLIDEFILES=$(addsuffix .ps, $(SLIDES)) @@ -21,6 +22,7 @@ mm0.ps: mm.fig LC_CTYPE=en_GB fig2dev -L ps -l dummy -z A4 -D-60 <$@.1 $o bck-lifetimes.ps: bck-err.txt.eps +macros.ps: serde-example.txt.eps macro-rules-example.txt.eps %.eps: %.fig iconv <$< >$@.1 -f UTF-8 -t ISO-8859-1 diff --git a/macro-rules-example.txt b/macro-rules-example.txt new file mode 100644 index 0000000..af3dc55 --- /dev/null +++ b/macro-rules-example.txt @@ -0,0 +1,3 @@ +macro_rules! debug { + ($g:expr, $($rhs:tt)*) => { (if debugp!($g) { eprint!($($rhs)*); }) } +} diff --git a/macros.fig b/macros.fig new file mode 100644 index 0000000..65d3daf --- /dev/null +++ b/macros.fig @@ -0,0 +1,24 @@ +#FIG 3.2 Produced by xfig version 3.2.6a +Landscape +Center +Metric +A4 +100.00 +Single +-2 +1200 2 +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 +2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5 + 0 serde-example.txt.eps + -1170 -2250 10800 -2250 10800 2430 -1170 2430 -1170 -2250 +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 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/serde-example.txt b/serde-example.txt new file mode 100644 index 0000000..c5c2f13 --- /dev/null +++ b/serde-example.txt @@ -0,0 +1,14 @@ +use serde::{Serialize, Deserialize}; + +#[derive(Serialize, Deserialize, Debug)] +struct Point { + x: i32, + y: i32, +} + +fn main() { + let point = Point { x: 1, y: 2 }; + + // Convert the Point to a JSON string. + let serialized = serde_json::to_string(&point).unwrap(); +... diff --git a/talk.txt b/talk.txt index 5440e07..2e5772d 100644 --- a/talk.txt +++ b/talk.txt @@ -227,10 +227,12 @@ hide the issue from the API's consumer. The awkwardness is tolerable. Rust does have macros. In fact it has two ways to define macros (one built on top of the other). The more sophisticated macro system is -very capable and has been used to really impressive effect. But it's -hard to use casually; and the simpler macro definition facility is -simultaneously too complicated and underpowered. So casual macro use -is slightly awkward. +very capable and has been used to really impressive effect. You can +see an example here. + +But it's hard to use casually; and the simpler macro definition +facility is simultaneously too complicated and underpowered. So +casual macro use is slightly awkward. [ cargo - dw posts, links ]