utkarshkukreti / markup.rs

A blazing fast, type-safe template engine for Rust.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't destructure in Markup

edward-shen opened this issue · comments

Hey!

I'm trying to destructure an struct in a markup parameter:

Foo(Bar {x, y, z}: Bar) {
    p { {x} }
}

But the compiler's expecting an : where the destructure is occuring.

For reference, I can do this in a normal function:

fn Foo(Bar {x, y, z}: Bar) { // ... }

Is this a bug or an unsupported feature?

I guess a simple workaround would be to destructure at the next available level, but I think this would be a great feature to add, if it's not a feature yet!

This is because markup creates a struct for the arguments. If you use a pattern on the left side, there's no way to know what the struct field should be called.

Closing as resolved. If you have any other questions, feel free to ask.