Skip to content

What is the correct way to set the value of an anonymous struct property on the rust side? #2650

Answered by ogoffart
Ethanwolfie asked this question in General
Discussion options

You must be logged in to vote

I assume you mean something like this

export component Foo {
    property <{x: int, a: string}> foo;
}

Then is indeed an anonymous struct in the native language. And the order is the alphabetical order of the fields.
It's like that for technical reason, because the type information doesn't have the exact order (although we could fix that) but then it would be a breaking change.

I think the best would be to declare an actual struct:

export struct Xa { x: int, a: string }

export component Foo {
    property <Xa> foo;
}

Then you have a non-annonymous struct that should be easier to handle.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@Ethanwolfie
Comment options

@Ethanwolfie
Comment options

Comment options

You must be logged in to vote
2 replies
@Ethanwolfie
Comment options

@ogoffart
Comment options

Answer selected by Ethanwolfie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants