Macros (macro_rules!)
Në shqip: Makrot në Rust
ShpjegimiSQ
Makrot në Rust (me ! në fund, si println! dhe vec!) shkruajnë kod për ty gjatë kompajlimit. Ndryshe nga makrot e C-së, janë të sigurta dhe kuptojnë strukturën e kodit. Makrot procedurale fuqizojnë #[derive].
EnglishEN
Rust macros (ending in !, like println! and vec!) write code for you at compile time. Unlike C macros, they're safe and understand the code's structure. Procedural macros power #[derive].
Si ta mendosh
Si një shabllon që e mbush vetë fletoren me tabela.
Lexoje në anglisht
Like a template that fills your notebook with tables automatically.
Shembull kodirust
macro_rules! katror {
($x:expr) => { $x * $x };
}
println!("{}", katror!(7)); // 49