Trending

#RustMacros

Latest posts tagged with #RustMacros on Bluesky

Latest Top
Trending

Posts tagged #RustMacros

Crafting Rust Macros: Lessons from Slint โ€” Olivier Goffart at Rust in Paris 2025 ๐Ÿฆ€ Conf
Crafting Rust Macros: Lessons from Slint โ€” Olivier Goffart at Rust in Paris 2025 ๐Ÿฆ€ Conf YouTube video by Rust in Paris ๐Ÿฆ€ Conf

๐ŸŽฅ Rust in Paris 2025 ๐Ÿฆ€

At the latest edition of Rust in Paris, Olivier Goffart delivered a talk on the power of Rust macros.

๐Ÿ‘‰ Watch the full talk: youtu.be/vE9EH1kOXOU

Huge thanks to Olivier ๐Ÿ™Œ

#RustLang #RustMacros #RustInParis #RustProgramming #OpenSource #Slint #RustCommunity #CppIntegration

6 5 0 0
macro_rules! create_function {     ($func_name:ident) => {         fn $func_name() {             println!("You called {:?}()", stringify!($func_name));         }     }; }  create_function!(foo); create_function!(bar);  fn main() {     foo();     bar(); }

macro_rules! create_function { ($func_name:ident) => { fn $func_name() { println!("You called {:?}()", stringify!($func_name)); } }; } create_function!(foo); create_function!(bar); fn main() { foo(); bar(); }

// notice how all the imports are revealed! #![feature(prelude_import)] #[prelude_import] use std::prelude::rust_2021::*; #[macro_use] extern crate std;  // notice how the function bodies are shown! fn foo() {     {         ::std::io::_print(format_args!("You called {0:?}()\n", "foo"));     }; } fn bar() {     {         ::std::io::_print(format_args!("You called {0:?}()\n", "bar"));     }; } fn main() {     foo();     bar(); }

// notice how all the imports are revealed! #![feature(prelude_import)] #[prelude_import] use std::prelude::rust_2021::*; #[macro_use] extern crate std; // notice how the function bodies are shown! fn foo() { { ::std::io::_print(format_args!("You called {0:?}()\n", "foo")); }; } fn bar() { { ::std::io::_print(format_args!("You called {0:?}()\n", "bar")); }; } fn main() { foo(); bar(); }

โšก #Rustlang Tip: cargo expand - Your X-ray Vision for Macros

cargo expand allows you to see the expanded code generated by macros, providing more insight into what's happening under the hood

Learn more here: docs.rs/crate/cargo-expand/0.1.3...

#RustMacros #Rust30by30 #Day13

0 0 0 0