utkarshkukreti / markup.rs

A blazing fast, type-safe template engine for Rust.
Apache License 2.0
350 stars 14 forks source link

Can't destructure in Markup #3

Closed edward-shen closed 5 years ago

edward-shen commented 5 years ago

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?

edward-shen commented 5 years ago

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!

utkarshkukreti commented 5 years ago

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.

utkarshkukreti commented 5 years ago

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