Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does auto-derived Getable only work on records and not Rust-originating structs? #591

Closed
t184256 opened this issue Jul 24, 2018 · 2 comments

Comments

@t184256
Copy link

t184256 commented Jul 24, 2018

Sorry if this is trivial, but I can't get a derived Getable to return from gluon to Rust. First experience with Rust and gluon, yadda yadda.

To get something that is sure to work and to be on the same page with @Marwes and @Laegluin, I have adapted the marshalling example to this: https://gist.github.com/t184256/3d969d4bf862d124ed1948dea9042466

I added

fn make_struct(s: String) -> Struct {
    Struct {string: s, int: 5, tuple: (0.1, 0.2)}
}

and tried to return the result of make_struct "Hello" to Rust. It fails with

thread 'main' panicked at 'Cannot find the field 'string'. Do the type definitions match?'

at <gluon_test::Struct as gluon_vm::api::Getable<'__vm>>::from_value

and I have no idea how to make the struct return to Rust land.

Meanwhile, returning a record with the required fields present is totally fine.

So, does auto-derived Getable::from_value only work on records and not proper Rust-originating instances of the structs in question? How can I return a struct that I already shoved into Gluon succesfully, unmodified? Could you guys write trivial examples as well and not dive into overcomplicated ones right away?

@t184256 t184256 changed the title Does auto-derived Getable only work on records and not instances of itself Does auto-derived Getable only work on records and not Rust-originating structs? Jul 24, 2018
Marwes added a commit to Marwes/gluon that referenced this issue Jul 24, 2018
Marwes added a commit to Marwes/gluon that referenced this issue Jul 24, 2018
@Marwes
Copy link
Member

Marwes commented Jul 24, 2018

Thanks for reporting, seems like you ran into a bug with the Pushable derive, fix in #593

Marwes added a commit to Marwes/gluon that referenced this issue Jul 24, 2018
@t184256
Copy link
Author

t184256 commented Jul 25, 2018

Great, specifying

gluon = { git = "https://github.com/Marwes/gluon", branch = "issue_591" }
gluon_vm = { git = "https://github.com/Marwes/gluon", branch = "issue_591" }
gluon_codegen = { git = "https://github.com/Marwes/gluon", branch = "issue_591" }

really fixed the problem I was having. Thanks!

bors bot added a commit that referenced this issue Jul 25, 2018
593: fix(vm): Correctly assign record field names in derive(Pushable) r=Marwes a=Marwes

Fixes #591

Co-authored-by: Markus Westerlind <marwes91@gmail.com>
@bors bors bot closed this as completed in #593 Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants