Crust of Rust: Declarative Macros

Crust of Rust: Declarative Macros

In this second Crust of Rust video, we cover declarative macros, macro_rules!, by re-implementing the vec! macro from the standard library. As part of that, we cover not only how to write these, but some of the gotchas and tricks you'll run into, and some common use-cases.

In this second Crust of Rust video, we cover declarative macros, macro_rules!, by re-implementing the vec! macro from the standard library. As part of that, we cover not only how to write these, but some of the gotchas and tricks you'll run into, and some common use-cases.

You can find the final code at https://gist.github.com/jonhoo/ec5788... , and the Little Book of Rust Macros at https://danielkeep.github.io/tlborm/b... .

0:00:00 Introduction 0:01:35 The vec macro 0:04:08 The Little Book of Rust Macros 0:05:17 Macro syntax and hygiene 0:16:42 The empty vector 0:19:26 Non-empty vectors 0:25:50 Macros v2 0:26:34 Macro delimiters 0:27:54 Declarative vs procedural macros 0:30:15 Repeated macro arguments 0:39:49 Trailing commas 0:44:10 Why are macros useful? 0:47:29 Vector by repetition 0:51:02 Macro rules readability 0:52:00 Invalid macro inputs 0:54:52 Test that something doesn't compile 0:56:50 Tidying up the patterns 0:59:05 Reallocations for repetition constructor 1:04:08 Macro argument trait bounds 1:06:40 "use" hygiene in macros 1:08:28 The standard library pattern 1:10:20 The need for counting 1:11:38 Eager macro errors 1:13:00 Counting in macros 1:24:48 Other ways of counting 1:27:27 Ensuring count is computed at compile time 1:28:32 Hiding internal macro patterns 1:31:13 Other collection literals 1:33:00 Comparing against the std implementation

☞ Crust of Rust: Lifetime Annotations ☞ Crust of Rust: Declarative Macros ☞ Crust of Rust: Iterators ☞ Crust of Rust: Smart Pointers and Interior Mutability ☞ Crust of Rust: Channels

rust programming

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

RUST on programming language

In this blog, I am going to run around and see the different aspects of programming language rust. And talk about the concepts that it introduces that are useful for various aspects of programming.

The Rust Programming Language - Understanding Loops in Rust

In this Rust programming language tutorial, we'll understanding Loops in Rust. Rust currently provides three approaches to performing some kind of iterative activity. They are: loop, while and for. The infinite loop is the simplest form of loop available in Rust. Rust also has a while loop. The for loop is used to loop a particular number of times

OS in Rust: An executable that runs on bare metal

This is the very first blog of the series that pertains to create a basic Operating System using Rust Programming Language. The aim of this series is to learn and understand the basics of Operating System. Through this series, you will get some ideas about the internal components of Operating System and how they interact with each other.

This Rust programming language

An introduction to the Tuples data type. This Rust programming language tutorial series is aimed at easing your training step by step. Rust is a systems leve...

Rust Casting, Shadowing, Consts and Static

A mix of topics of casting, shadowing, constants and static variables inside the Rust Programming Language. This Rust programming language tutorial series is aimed at easing your training step by step.