Lab 07 - Unsafe and FFI, and procedural macros
This lab session is made of two parts: unsafe/FFI first, macros second.
Part 1: unsafe and FFI
You will learn how to:
- write a build script;
- interface with a C package using bindgen;
- write a higher level interface for your bindings.
By the end of this part you will be familiar with the Rust tools and techniques used to safely interface with a foreign language.
(This part has been designed by Guillaume Duc. The lab instructions have been translated from French to English. All translation mistakes are ours.)
Part 2: writing a procedural macro
You will learn how to:
- write a procedural macro which works directly on the
TokenStream
; - write a procedural macro which uses a visitor pattern;
- write a derive macro that adds new capabilities to a structure.
You are not expected to complete all three macro exercises in the alloted time. Each exercise is self contained, you can choose what you want to work on after reading each exercise text.
By the end of this part you will be able to write procedural macros to enhance the Rust language capabilities.