chiark / gitweb /
wip
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 16 May 2019 01:03:41 +0000 (02:03 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 16 May 2019 01:03:41 +0000 (02:03 +0100)
macros.fig
serde-example.txt

index 5d9c95fe365568cf00a6727cfaa9f0bb16427d61..10e44084a32c219fa3ba6f555753f94dc4cb815c 100644 (file)
@@ -7,18 +7,19 @@ A4
 Single
 -2
 1200 2
-1 2 0 2 1 7 50 -1 -1 0.000 1 0.0000 3015 -1395 2565 315 450 -1710 5580 -1080
 2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 2
         -1350 2970 10800 2970
-2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5
-       0 serde-example.txt.eps
-        -1170 -2250 11340 -2250 11340 2512 -1170 2512 -1170 -2250
 2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5
        0 macro-rules-example.txt.eps
         -1170 3330 9054 3330 9054 5712 -1170 5712 -1170 3330
-4 0 1 50 -1 0 30 0.0000 4 330 2175 8280 1530 Awesome!\001
+2 5 0 1 0 -1 60 -1 -1 0.000 0 0 -1 0 0 5
+       0 serde-example.txt.eps
+        -1170 -2250 10785 -2250 10785 2512 -1170 2512 -1170 -2250
+2 2 0 2 1 7 50 -1 -1 0.000 0 0 -1 0 0 5
+        720 -1170 5760 -1170 5760 -1620 720 -1620 720 -1170
 4 0 4 50 -1 0 30 0.0000 4 435 7410 3600 5310 What a syntax for something simple!\001
-4 0 1 50 -1 0 27 0.0000 4 420 5085 2520 -270 You can do this in a library!\001
-4 0 1 50 -1 0 27 0.0000 4 315 4800 2520 -720 Not a built in Rust feature.\001
-4 0 1 50 -1 0 24 0.0000 4 360 5520 2520 360 Only Common Lisp can beat this\001
 4 0 4 50 -1 0 26 0.0000 4 405 9450 1800 5760 (and this macro doesn't even always work quite right)\001
+4 0 1 50 -1 0 27 0.0000 4 315 4800 5850 -1620 Not a built in Rust feature.\001
+4 0 1 50 -1 0 27 0.0000 4 420 5085 6030 -720 You can do this in a library!\001
+4 0 1 50 -1 0 24 0.0000 4 360 5520 6030 -360 Only Common Lisp can beat this\001
+4 0 1 50 -1 0 30 0.0000 4 330 2175 8280 1890 Awesome!\001
index c5c2f130f716f9ab4df0c8a60614696cf955c1a6..8428397a13755b0a18bc825c7838431d9106137f 100644 (file)
@@ -1,14 +1,13 @@
 use serde::{Serialize, Deserialize};
 
 #[derive(Serialize, Deserialize, Debug)]
-struct Point {
-    x: i32,
-    y: i32,
-}
+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();
-...
+    let j = serde_json::to_string(&point).unwrap();
+
+    // Parse the JSON string as a Point.
+    let p2: Point = serde_json::from_str(&j).unwrap();