Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
proc-macro-workshop
Learn to write Rust procedural macros [Rust Latam conference, Montevideo Uruguay, March 2019]
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
For me the real cool stuff is made possible through proc macros. They take as input a stream of tokens and output a stream of tokens. For example you can use these to make embedded DSLs in rust (example JSX in rust).
Or you can pair them with crates like syn, and quote for quasi-quoting, and then it's easy to make transformations on the AST of Rust input code. A lot of libraries do this for code-generation and hiding away a lot of complexity (example wasm-bindgen).
Or you can pair them with crates like syn, and quote for quasi-quoting, and then it's easy to make transformations on the AST of Rust input code. A lot of libraries do this for code-generation and hiding away a lot of complexity (example wasm-bindgen).
Or you can pair them with crates like syn, and quote for quasi-quoting, and then it's easy to make transformations on the AST of Rust input code. A lot of libraries do this for code-generation and hiding away a lot of complexity (example wasm-bindgen).
I recommend you play around with some libraries that use proc macros and then use cargo-expand (vscode + rust-analyzer has a feature like this too) to see the generated code from the macro. For example, try looking at the result of expanding wasm-bindgen's basic example code
David Tolnay’s procedural Rust workshop: https://github.com/dtolnay/proc-macro-workshop
Also I suggest his case studies repo since you are looking at what is possible: https://github.com/dtolnay/case-studies