Annotate Command and Subscription with #[must_use]

Calling a function returning one of these types without using it is
almost certainly a mistake. Luckily Rust's `#[must_use]` can help warn
about this.
This commit is contained in:
Ian Douglas Scott 2023-01-26 16:10:45 -08:00
parent 2dea5fe058
commit 2e4aefa7fc
3 changed files with 3 additions and 0 deletions

View file

@ -1,4 +1,5 @@
/// A set of asynchronous actions to be performed by some runtime.
#[must_use = "`Command` must be returned to runtime to take effect"]
#[derive(Debug)]
pub struct Command<T>(Internal<T>);

View file

@ -20,6 +20,7 @@ use crate::BoxStream;
/// `Hasher`.
///
/// [`Command`]: crate::Command
#[must_use = "`Subscription` must be returned to runtime to take effect"]
pub struct Subscription<Hasher, Event, Output> {
recipes: Vec<Box<dyn Recipe<Hasher, Event, Output = Output>>>,
}

View file

@ -11,6 +11,7 @@ use std::fmt;
use std::future::Future;
/// A set of asynchronous actions to be performed by some runtime.
#[must_use = "`Command` must be returned to runtime to take effect"]
pub struct Command<T>(iced_futures::Command<Action<T>>);
impl<T> Command<T> {