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

VecDeque can't be sent through Rune #693

Open
HoloTheDrunk opened this issue Apr 23, 2024 · 3 comments
Open

VecDeque can't be sent through Rune #693

HoloTheDrunk opened this issue Apr 23, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@HoloTheDrunk
Copy link

HoloTheDrunk commented Apr 23, 2024

Attempt

#[derive(Any)]
struct MyStruct {
    #[rune(get)]
    dvec: VecDeque<i64>,
}

Expected behaviour
The code compiles without issue.

Actual behaviour
The compiler throws this error:

error[E0277]: the trait bound `{closure@src/main.rs:8:10: 8:13}: InstanceFunction<_, Plain>` is not satisfied
    --> src/main.rs:8:10
     |
8    |   #[derive(Any)]
     |            ^^^ the trait `InstanceFunction<_, Plain>` is not implemented for closure `{closure@src/main.rs:8:10: 8:13}`
9    |   struct MyStruct {
10   | /     #[rune(get)]
11   | |     dvec: VecDeque<i64>,
     | |_______________________- required by a bound introduced by this call
     |
note: required by a bound in `rune::Module::field_function`
    --> /home/RDuhen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rune-0.13.2/src/module/module.rs:1603:12
     |
1595 |     pub fn field_function<N, F, A>(
     |            -------------- required by a bound in this associated function
...
1603 |         F: InstanceFunction<A, Plain>,
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Module::field_function`

Note
Another error message I have not been able to reproduce said something along the lines of "VecDeque is missing a Rune clone implementation", which could be what's preventing passing VecDeques to a Rune VM.

@udoprog udoprog added the enhancement New feature or request label Apr 23, 2024
@udoprog
Copy link
Collaborator

udoprog commented Apr 23, 2024

I think it's just lacking FromValue and ToValue implementations.

You'd also be encouraged to use rune::alloc::vec_deque, and the mapping would go to the VecDeque in the collections module.

@HoloTheDrunk
Copy link
Author

Ah, using rune::alloc::VecDeque leads to the Clone error I couldn't get again.

error[E0277]: the trait bound `rune::alloc::VecDeque<i64>: Clone` is not satisfied
 --> src/main.rs:8:10
  |
8 | #[derive(Any)]
  |          ^^^ the trait `Clone` is not implemented for `rune::alloc::VecDeque<i64>`
  |
  = note: this error originates in the derive macro `Any` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `{closure@src/main.rs:8:10: 8:13}: InstanceFunction<_, Plain>` is not satisfied
    --> src/main.rs:8:10
     |
8    |   #[derive(Any)]
     |            ^^^ the trait `InstanceFunction<_, Plain>` is not implemented for closure `{closure@src/main.rs:8:10: 8:13}`
9    |   struct MyStruct {
10   | /     #[rune(get)]
11   | |     dvec: rune::alloc::VecDeque<i64>,
     | |____________________________________- required by a bound introduced by this call
     |
note: required by a bound in `rune::Module::field_function`
    --> /home/RDuhen/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rune-0.13.2/src/module/module.rs:1603:12
     |
1595 |     pub fn field_function<N, F, A>(
     |            -------------- required by a bound in this associated function
...
1603 |         F: InstanceFunction<A, Plain>,
     |            ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Module::field_function`

@udoprog
Copy link
Collaborator

udoprog commented Apr 25, 2024

Hmm. We should really be using TryClone and not Clone in the macro that builds the getter.

@SWW13 SWW13 mentioned this issue Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants