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

Make iced::Result Send + Sync #516

Closed
Tarnadas opened this issue Sep 9, 2020 · 2 comments · Fixed by #719
Closed

Make iced::Result Send + Sync #516

Tarnadas opened this issue Sep 9, 2020 · 2 comments · Fixed by #719
Labels
improvement An internal improvement
Milestone

Comments

@Tarnadas
Copy link

Tarnadas commented Sep 9, 2020

With the recent addition of error handling, I tried to wrap an iced::Result with an anyhow::Result, but it's not working because I get this error:

error[E0277]: `(dyn StdError + 'static)` cannot be sent between threads safely                                                                                                                                                                                               
  --> src\main.rs:51:23
   |
51 |     App::run(settings)?;
   |                       ^ `(dyn StdError + 'static)` cannot be sent between threads safely
   |
   = help: the trait `std::marker::Send` is not implemented for `(dyn StdError + 'static)`
   = note: required because of the requirements on the impl of `std::marker::Send` for `Unique<(dyn StdError + 'static)>`
   = note: required because it appears within the type `Box<(dyn StdError + 'static)>`
   = note: required because it appears within the type `iced::Error`
   = note: required because of the requirements on the impl of `From<iced::Error>` for `anyhow::Error`
   = note: required by `std::convert::From::from`

error[E0277]: `(dyn StdError + 'static)` cannot be shared between threads safely
  --> src\main.rs:51:23
   |
51 |     App::run(settings)?;
   |                       ^ `(dyn StdError + 'static)` cannot be shared between threads safely
   |
   = help: the trait `Sync` is not implemented for `(dyn StdError + 'static)`
   = note: required because of the requirements on the impl of `Sync` for `Unique<(dyn StdError + 'static)>`
   = note: required because it appears within the type `Box<(dyn StdError + 'static)>`
   = note: required because it appears within the type `iced::Error`
   = note: required because of the requirements on the impl of `From<iced::Error>` for `anyhow::Error`
   = note: required by `std::convert::From::from`

Example code:

use anyhow::Result;

fn main() -> Result<()> {
    use iced::{Application, Settings};

    App::run(Settings::default())?;
    Ok(())
}
@hecrj hecrj added the improvement An internal improvement label Sep 10, 2020
@hecrj hecrj added this to the 0.2.0 milestone Sep 10, 2020
@hecrj hecrj modified the milestones: 0.2.0, 0.3.0 Nov 26, 2020
@brendanzab
Copy link

I'm running into this too. I think it might be because WindowCreationFailed(Box<dyn std::error::Error>) needs a more restrictive trait object?

@brendanzab
Copy link

brendanzab commented Nov 29, 2020

A workaround is to do something like:

// FIXME: `iced::Error` is not `Send + Sync`, and so is incompatible with `anyhow::Result`.
// See this issue for more information: https://github.com/hecrj/iced/issues/516
pikelet_editor::run().map_err(|err| anyhow!("{}", err))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement An internal improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants