Split macro contents into files
⚓ Rust 📅 2025-11-03 👤 surdeus 👁️ 7I've a macro that does complex processing steps to achieve hierarchical structures with dynamic dispatch, which is very useful when implementing a compiler's semantic model.
Unfortunately, every struct must appear inside the macro. E.g. the macro results in a closed/final/sealed set of structs.
It looks like this:
use hydroperx_sem::sem;
sem! {
// arena type.
type Arena = Arena;
/// Basemost struct representing a semantic symbol.
/// For instance, a var slot, a method or a class.
pub struct Symbol {
/// Declaration name.
pub fn name(&self) -> String {
"".into()
}
}
/// Represents a method.
pub struct Method: Symbol {
let ref _name: String = "".into();
pub fn Method(name: &str) {
super();
self.set__name(name.to_owned());
}
pub override fn name(&self) -> String {
self._name()
}
}
}
I ask again if there's now a way to split that into multiple files (something like include!(...)).
3 posts - 2 participants
🏷️ Rust_feed