Fix Send requirements in WebAssembly builds

This commit is contained in:
Héctor Ramón Jiménez 2025-08-29 09:07:19 +02:00
parent 4991a1a7f3
commit 5417b630a5
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
6 changed files with 14 additions and 20 deletions

View file

@ -413,7 +413,7 @@ mod internal {
}
}
#[cfg(feature = "hot")]
#[cfg(all(feature = "hot", not(target_arch = "wasm32")))]
mod hot {
use std::collections::BTreeSet;
use std::sync::atomic::{self, AtomicBool};
@ -478,7 +478,7 @@ mod hot {
}
}
#[cfg(not(feature = "hot"))]
#[cfg(any(not(feature = "hot"), target_arch = "wasm32"))]
mod hot {
pub fn init() {}
@ -486,7 +486,7 @@ mod hot {
f()
}
pub fn on_hotpatch(_f: impl Fn() + Send + Sync + 'static) {}
pub fn on_hotpatch(_f: impl Fn()) {}
pub fn is_stale() -> bool {
false

View file

@ -15,7 +15,7 @@ use crate::core::text;
use crate::core::theme;
use crate::core::window;
use crate::core::{Element, Font, Settings};
use crate::futures::{Executor, MaybeSend, Subscription};
use crate::futures::{Executor, Subscription};
use crate::graphics::compositor;
use crate::runtime::Task;
@ -29,7 +29,7 @@ pub trait Program: Sized {
type State;
/// The message of the program.
type Message: MaybeSend + 'static;
type Message: Send + 'static;
/// The theme of the program.
type Theme: Default + theme::Base;

View file

@ -36,8 +36,7 @@ use crate::shell;
use crate::theme;
use crate::window;
use crate::{
Element, Executor, Font, MaybeSend, Preset, Result, Settings, Size,
Subscription, Task,
Element, Executor, Font, Preset, Result, Settings, Size, Subscription, Task,
};
use iced_debug as debug;
@ -83,7 +82,7 @@ pub fn application<State, Message, Theme, Renderer>(
) -> Application<impl Program<State = State, Message = Message, Theme = Theme>>
where
State: 'static,
Message: MaybeSend + 'static,
Message: Send + 'static,
Theme: Default + theme::Base,
Renderer: program::Renderer,
{
@ -102,7 +101,7 @@ where
impl<State, Message, Theme, Renderer, Boot, Update, View> Program
for Instance<State, Message, Theme, Renderer, Boot, Update, View>
where
Message: MaybeSend + 'static,
Message: Send + 'static,
Theme: Default + theme::Base,
Renderer: program::Renderer,
Boot: self::Boot<State, Message>,
@ -201,7 +200,7 @@ impl<P: Program> Application<P> {
#[cfg(all(feature = "debug", not(feature = "tester")))]
let program = iced_devtools::attach(self);
#[cfg(any(not(feature = "debug"), target_arch = "wasm32"))]
#[cfg(not(any(feature = "tester", feature = "debug")))]
let program = self;
Ok(shell::run(program)?)

View file

@ -6,8 +6,7 @@ use crate::shell;
use crate::theme;
use crate::window;
use crate::{
Element, Executor, Font, MaybeSend, Preset, Result, Settings, Subscription,
Task,
Element, Executor, Font, Preset, Result, Settings, Subscription, Task,
};
use iced_debug as debug;
@ -31,7 +30,7 @@ pub fn daemon<State, Message, Theme, Renderer>(
) -> Daemon<impl Program<State = State, Message = Message, Theme = Theme>>
where
State: 'static,
Message: MaybeSend + 'static,
Message: Send + 'static,
Theme: Default + theme::Base,
Renderer: program::Renderer,
{
@ -50,7 +49,7 @@ where
impl<State, Message, Theme, Renderer, Boot, Update, View> Program
for Instance<State, Message, Theme, Renderer, Boot, Update, View>
where
Message: MaybeSend + 'static,
Message: Send + 'static,
Theme: Default + theme::Base,
Renderer: program::Renderer,
Boot: application::Boot<State, Message>,

View file

@ -528,7 +528,6 @@ pub use crate::core::{
pub use crate::program::Preset;
pub use crate::program::message;
pub use crate::runtime::exit;
pub use crate::runtime::futures::MaybeSend;
pub use iced_futures::Subscription;
pub use Alignment::Center;
@ -698,7 +697,7 @@ pub fn run<State, Message, Theme, Renderer>(
) -> Result
where
State: Default + 'static,
Message: MaybeSend + message::MaybeDebug + message::MaybeClone + 'static,
Message: Send + message::MaybeDebug + message::MaybeClone + 'static,
Theme: Default + theme::Base + 'static,
Renderer: program::Renderer + 'static,
{

View file

@ -77,10 +77,7 @@ impl<T: 'static> Proxy<T> {
///
/// Note: This skips the backpressure mechanism with an unbounded
/// channel. Use sparingly!
pub fn send(&self, value: T)
where
T: std::fmt::Debug,
{
pub fn send(&self, value: T) {
self.send_action(Action::Output(value));
}