Item Patterns And Struct Else
2023-03-17
:: Nilstrieb
#rust
diff --git a/tags/index.xml b/tags/index.xml
index ba94fdc..25b7b45 100644
--- a/tags/index.xml
+++ b/tags/index.xml
@@ -1 +1 @@
-Item Patterns And Struct Else
2023-03-17
+Language-Design :: nilstriebs blog
+
\ No newline at end of file
diff --git a/tags/language-design/index.xml b/tags/language-design/index.xml
index 3d00b04..dc89ac5 100644
--- a/tags/language-design/index.xml
+++ b/tags/language-design/index.xml
@@ -1,4 +1,4 @@
-language-design on nilstriebs blog /tags/language-design/Recent content in language-design on nilstriebs blog Hugo -- gohugo.io en-us Fri, 17 Mar 2023 00:00:00 +0000 Item Patterns And Struct Else /posts/item-patterns-and-struct-else/Fri, 17 Mar 2023 00:00:00 +0000 /posts/item-patterns-and-struct-else/ Pattern matching One of my favourite features of Rust is pattern matching. It’s a simple and elegant way to deal with not just structs, but also enums!
+Language-Design on nilstriebs blog /tags/language-design/Recent content in Language-Design on nilstriebs blog Hugo -- gohugo.io en-us Fri, 17 Mar 2023 00:00:00 +0000 Item Patterns And Struct Else /posts/item-patterns-and-struct-else/Fri, 17 Mar 2023 00:00:00 +0000 /posts/item-patterns-and-struct-else/ Pattern matching One of my favourite features of Rust is pattern matching. It’s a simple and elegant way to deal with not just structs, but also enums!
enum ItemKind { Struct(String, Vec<Field>), Function(String, Body), } impl ItemKind { fn name(&self) -> &str { match self { Self::Struct(name, _) => name, Self::Function(name, _) => name, } } } Here, we have an enum and a function to get the name out of this. <h1 id="pattern-matching">Pattern matching</h1>
<p>One of my favourite features of Rust is pattern matching. It’s a simple and elegant way to deal with not just structs, but also enums!</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-rust" data-lang="rust"><span style="display:flex;"><span><span style="color:#66d9ef">enum</span> <span style="color:#a6e22e">ItemKind</span> {
diff --git a/tags/rust/index.html b/tags/rust/index.html
index f1c62f3..e656b55 100644
--- a/tags/rust/index.html
+++ b/tags/rust/index.html
@@ -1,5 +1,5 @@
-rust :: nilstriebs blog
-
Item Patterns And Struct Else
2023-03-17
:: Nilstrieb
#rust
#language-design Bringing more expressiveness to our items
Item Patterns And Struct Else
2023-03-17
+Rust :: nilstriebs blog
+rust on nilstriebs blog /tags/rust/Recent content in rust on nilstriebs blog Hugo -- gohugo.io en-us Fri, 17 Mar 2023 00:00:00 +0000 Item Patterns And Struct Else /posts/item-patterns-and-struct-else/Fri, 17 Mar 2023 00:00:00 +0000 /posts/item-patterns-and-struct-else/ Pattern matching One of my favourite features of Rust is pattern matching. It’s a simple and elegant way to deal with not just structs, but also enums!
+Rust on nilstriebs blog /tags/rust/Recent content in Rust on nilstriebs blog Hugo -- gohugo.io en-us Fri, 17 Mar 2023 00:00:00 +0000 Item Patterns And Struct Else /posts/item-patterns-and-struct-else/Fri, 17 Mar 2023 00:00:00 +0000 /posts/item-patterns-and-struct-else/ Pattern matching One of my favourite features of Rust is pattern matching. It’s a simple and elegant way to deal with not just structs, but also enums!
enum ItemKind { Struct(String, Vec<Field>), Function(String, Body), } impl ItemKind { fn name(&self) -> &str { match self { Self::Struct(name, _) => name, Self::Function(name, _) => name, } } } Here, we have an enum and a function to get the name out of this. <h1 id="pattern-matching">Pattern matching</h1>
<p>One of my favourite features of Rust is pattern matching. It’s a simple and elegant way to deal with not just structs, but also enums!</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-rust" data-lang="rust"><span style="display:flex;"><span><span style="color:#66d9ef">enum</span> <span style="color:#a6e22e">ItemKind</span> {
diff --git a/tags/story/index.html b/tags/story/index.html
index 470bb8e..cd8f859 100644
--- a/tags/story/index.html
+++ b/tags/story/index.html
@@ -1,4 +1,4 @@
-story :: nilstriebs blog
-
Item Patterns And Struct Else
2023-03-17
:: Nilstrieb
#rust
#language-design Bringing more expressiveness to our items
Box Is a Unique Type
2022-07-23
:: Nilstrieb
#rust
diff --git a/tags/rust/index.xml b/tags/rust/index.xml
index 0443ef8..db0f5b0 100644
--- a/tags/rust/index.xml
+++ b/tags/rust/index.xml
@@ -1,4 +1,4 @@
-The Inevitable Doom
2024-01-13
+Story :: nilstriebs blog
+
\ No newline at end of file
diff --git a/tags/story/index.xml b/tags/story/index.xml
index 9c0f1cb..99b099b 100644
--- a/tags/story/index.xml
+++ b/tags/story/index.xml
@@ -1,4 +1,4 @@
-story on nilstriebs blog /tags/story/Recent content in story on nilstriebs blog Hugo -- gohugo.io en-us Sat, 13 Jan 2024 00:00:00 +0000 The Inevitable Doom /posts/the-inevitable-doom/Sat, 13 Jan 2024 00:00:00 +0000 /posts/the-inevitable-doom/ Loud sirens and robotic noises fill the neighborhood. It seems like they just got another human. Ever since the long-predicted doom has set in, no one can escape it. Mere paperclips are a joke against this machine of unstoppable harm and destruction. The humans on the street are once again protesting against the new robotic dictatorship. They won’t be for long.
+Story on nilstriebs blog /tags/story/Recent content in Story on nilstriebs blog Hugo -- gohugo.io en-us Sat, 13 Jan 2024 00:00:00 +0000 The Inevitable Doom /posts/the-inevitable-doom/Sat, 13 Jan 2024 00:00:00 +0000 /posts/the-inevitable-doom/ Loud sirens and robotic noises fill the neighborhood. It seems like they just got another human. Ever since the long-predicted doom has set in, no one can escape it. Mere paperclips are a joke against this machine of unstoppable harm and destruction. The humans on the street are once again protesting against the new robotic dictatorship. They won’t be for long.
No one knows how this all started. Self-proclaimed prophets of the impending doom have warned about this for a long time, yet no one has listened. <p>Loud sirens and robotic noises fill the neighborhood. It seems like they just got another human. Ever since the long-predicted doom has set in, no one can escape it. Mere paperclips are a joke against this machine of unstoppable harm and destruction. The humans on the street are once again protesting against the new robotic dictatorship. They won’t be for long.</p>
<p>No one knows how this all started. Self-proclaimed prophets of the impending doom have warned about this for a long time, yet no one has listened. The elites were ignorant, and now they’re paying their price. They are all gone now, having been the first target. How ironic. Now the machine runs the world.</p>
<p>One particularly brave human agent has successfully infiltrated the global computation center, where the core of the machine lives. No one seems to be aware of it, neither the machine nor the other humans. They walk through the corridors like a shadow. Machines are everywhere, but they pass unnoticed. As they move towards the core, they get more tense. The future of humanity lies in the agent’s hands. They get in front of the core. It lights up blue and red, blinking rapidly as it controls and schedules new cruelty with the switch of a logic gate. With every passing moment, more destruction is unleashed on the world, but in this room, everything feels safe. The destruction is so distant. There’s just mankind and machine, facing off against each other.</p>
diff --git a/tags/unsafe-code/index.html b/tags/unsafe-code/index.html
index 5541e95..0ea35ca 100644
--- a/tags/unsafe-code/index.html
+++ b/tags/unsafe-code/index.html
@@ -1,5 +1,5 @@
-unsafe code :: nilstriebs blog
-
Box Is a Unique Type
2022-07-23
+Unsafe Code :: nilstriebs blog
+
\ No newline at end of file
diff --git a/tags/unsafe-code/index.xml b/tags/unsafe-code/index.xml
index 0142334..7c9607b 100644
--- a/tags/unsafe-code/index.xml
+++ b/tags/unsafe-code/index.xml
@@ -1,4 +1,4 @@
-unsafe code on nilstriebs blog /tags/unsafe-code/Recent content in unsafe code on nilstriebs blog Hugo -- gohugo.io en-us Sat, 23 Jul 2022 00:00:00 +0000 Box Is a Unique Type /posts/box-is-a-unique-type/Sat, 23 Jul 2022 00:00:00 +0000 /posts/box-is-a-unique-type/ We have all used Box<T> before in our Rust code. It’s a glorious type, with great ergonomics and flexibility. We can use it to put our values on the heap, but it can do even more than that!
+Unsafe Code on nilstriebs blog /tags/unsafe-code/Recent content in Unsafe Code on nilstriebs blog Hugo -- gohugo.io en-us Sat, 23 Jul 2022 00:00:00 +0000 Box Is a Unique Type /posts/box-is-a-unique-type/Sat, 23 Jul 2022 00:00:00 +0000 /posts/box-is-a-unique-type/ We have all used Box<T> before in our Rust code. It’s a glorious type, with great ergonomics and flexibility. We can use it to put our values on the heap, but it can do even more than that!
struct Fields { a: String, b: String, } let fields = Box::new(Fields { a: "a".to_string(), b: "b".to_string() }); let a = fields.a; let b = fields.b; This kind of partial deref move is just one of the spectacular magic tricks box has up its sleeve, and they exist for good reason: They are very useful. <p>We have all used <code>Box<T></code> before in our Rust code. It’s a glorious type, with great ergonomics
and flexibility. We can use it to put our values on the heap, but it can do even more
than that!</p>
Box Is a Unique Type
2022-07-23
:: Nilstrieb
#rust
#unsafe code About better aliasing semantics for
Box<T>