summaryrefslogtreecommitdiff
path: root/rust/graph
diff options
context:
space:
mode:
Diffstat (limited to 'rust/graph')
-rw-r--r--rust/graph/Cargo.toml4
-rw-r--r--rust/graph/graph2.rs17
2 files changed, 21 insertions, 0 deletions
diff --git a/rust/graph/Cargo.toml b/rust/graph/Cargo.toml
index adabedc..eb0841b 100644
--- a/rust/graph/Cargo.toml
+++ b/rust/graph/Cargo.toml
@@ -9,3 +9,7 @@ itertools = "0.4.15"
[[bin]]
name = "graph"
path = "graph.rs"
+
+[[bin]]
+name = "graph2"
+path = "graph2.rs"
diff --git a/rust/graph/graph2.rs b/rust/graph/graph2.rs
new file mode 100644
index 0000000..1e57f19
--- /dev/null
+++ b/rust/graph/graph2.rs
@@ -0,0 +1,17 @@
+#[derive(Debug)]
+struct Node<'a> {
+ label: i32,
+ next: Option<&'a Node<'a>>,
+}
+
+
+fn main () {
+ let mut n = Node { label: 1, next: None };
+ unsafe {
+ let raw = &mut n as *mut Node;
+ (*raw).next = Some(&n);
+ }
+ println!("{}", n.label);
+ println!("{}", n.next.unwrap().label);
+ println!("{}", n.next.unwrap().next.unwrap().label);
+}