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

[Compile error] - Uploading files in WASM #6

Closed
margual56 opened this issue Jan 28, 2023 · 4 comments · Fixed by #37
Closed

[Compile error] - Uploading files in WASM #6

margual56 opened this issue Jan 28, 2023 · 4 comments · Fixed by #37
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@margual56
Copy link
Collaborator

It gives the following error:

error[E0382]: borrow of moved value: `self`
   --> src/window.rs:298:59
    |
225 |                               wasm_bindgen_futures::spawn_local(async move {
    |  __________________________________________________________________________-
226 | |                                 let file = task.await;
227 | |
228 | |                                 if let Some(file) = file {
...   |
232 | |                                         Ok(s) => self.restart(&s),
    | |                                                  ---- variable moved due to use in generator
...   |
235 | |                                 }
236 | |                             });
    | |_____________________________- value moved here
...
298 |                       egui::ScrollArea::vertical().show(ui, |my_ui: &mut Ui| {
    |                                                             ^^^^^^^^^^^^^^^^ value borrowed here after move
299 |                           let editor = my_ui.code_editor(&mut self.code);
    |                                                               --------- borrow occurs due to use in closure
    |
    = note: move occurs because `self` has type `&mut MyApp`, which does not implement the `Copy` trait

error[E0521]: borrowed data escapes outside of associated function
   --> src/window.rs:225:29
    |
165 |       fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
    |                 ---------
    |                 |
    |                 `self` is a reference that is only valid in the associated function body
    |                 let's call the lifetime of this reference `'1`
...
225 | /                             wasm_bindgen_futures::spawn_local(async move {
226 | |                                 let file = task.await;
227 | |
228 | |                                 if let Some(file) = file {
...   |
235 | |                                 }
236 | |                             });
    | |                              ^
    | |                              |
    | |______________________________`self` escapes the associated function body here
    |                                argument requires that `'1` must outlive `'static`

error[E0382]: borrow of moved value: `self`
   --> src/window.rs:308:49
    |
165 |     fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
    |               --------- move occurs because `self` has type `&mut MyApp`, which does not implement the `Copy` trait
...
217 |             .show(ctx, |ui| {
    |                        ---- value moved into closure here
...
232 |                                         Ok(s) => self.restart(&s),
    |                                                  ---- variable moved due to use in closure
...
308 |         egui::CentralPanel::default().show(ctx, |main_panel| {
    |                                                 ^^^^^^^^^^^^ value borrowed here after move
...
364 |                         if self.process_turing_controls(ui, &ctx, editor_focused, &lang) {
    |                            ---- borrow occurs due to use in closure

Some errors have detailed explanations: E0382, E0521.
For more information about an error, try `rustc --explain E0382`.
error: could not compile `turing-machine` due to 3 previous errors
@margual56 margual56 added bug Something isn't working help wanted Extra attention is needed labels Jan 28, 2023
@margual56 margual56 self-assigned this Jan 28, 2023
@margual56
Copy link
Collaborator Author

margual56 commented Jan 28, 2023

The code with the issue can be found here: src/window.rs#L222

@margual56
Copy link
Collaborator Author

That code is based on the rfd example

@margual56 margual56 pinned this issue Feb 7, 2023
@margual56
Copy link
Collaborator Author

A new attempt has been done in commit 17c351a1ced79f, with the functionality to download a modified file.

However, I cannot make it upload files because the function needs to be asynchronous, which makes the self reference to not live long enough, thus making impossible to update the attributes in self.

@margual56 margual56 mentioned this issue Aug 23, 2023
margual56 added a commit that referenced this issue Aug 23, 2023
* Fix loading a file

* Fixes loading in wasm, adds downloading files (fixes issue #6)
@margual56
Copy link
Collaborator Author

Closed by #36

margual56 added a commit that referenced this issue Aug 24, 2023
* Fixes issue #30

* Adds code for right-click menu for TextEdit
Does not work because TextEdit lacks Sense(click)
Thought for issue #32

* Add tooltip for issue #31

* Fix wasm I/O (#36)

* Fix loading a file

* Fixes loading in wasm, adds downloading files (fixes issue #6)

* Final touches for config. Closes #34

* Add survey, closes #35

* Add reset config if incompatible

* Update changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant