Ah, thank you both for that. That limitation on code generation
currently puts a damper on my attempt at a semi-convenient work-around
for the template system's lack of support for integer parameters. I
don't seem to be able to define structs and trait implementations
within the {...} and have them be accessible to the outer scope. Any
other possibly hacks around this? If not, I suppose I will wait for
rust to add support for what I would like to do (either in the
template system or the macro system).
You can put a module inside of the macro and the `pub use` that module
to bring it into scope. For example:
```rust
pub use self::macro::Vec3f;
macro_rules! declare
(
($Type:ident, $Component:ty) =>
(
mod macro
{
pub struct $Type
{
x: $Component,
y: $Component,
z: $Component
}
impl $Type
{
pub fn new(nx: $Component, ny: $Component, nz: $Component) -> $Type
{ $Type{ x: nx, y: ny, z: nz } }
}
}
);
)
declare!(Vec3f, f32)
```
Cheers,
Jeaye
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev