Files
natter/src/context/macros.rs

38 lines
1.1 KiB
Rust
Raw Normal View History

/// Write the implementation for the render ast node.
///
/// This exists to make changing the type signature easier.
macro_rules! render {
($rstruct:ident, $istruct:ident, $original:ident, $render_context:ident, $fnbody:tt) => {
impl $rstruct {
pub(crate) fn new(
render_context: RenderContext<'_>,
original: &$istruct,
) -> Result<$rstruct, CustomError> {
let $original = original;
let $render_context = render_context;
$fnbody
}
}
};
}
pub(crate) use render;
/// Write the implementation for a render ast node that has no fields.
///
/// This exists to make changing the type signature easier.
macro_rules! rnoop {
($rstruct:ident, $istruct:ident) => {
impl $rstruct {
pub(crate) fn new(
_render_context: RenderContext<'_>,
_original: &$istruct,
) -> Result<$rstruct, CustomError> {
Ok($rstruct {})
}
}
};
}
pub(crate) use rnoop;