Write missing documentation in iced_native

This commit is contained in:
Héctor Ramón Jiménez 2022-08-05 05:15:41 +02:00
parent 13dd1ca0a8
commit 66f7d43dc9
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
8 changed files with 81 additions and 2 deletions

View file

@ -3,13 +3,17 @@ use crate::widget::Id;
use iced_futures::MaybeSend;
/// An operation to be performed on the widget tree.
#[allow(missing_debug_implementations)]
pub struct Action<T>(Box<dyn Operation<T>>);
impl<T> Action<T> {
/// Creates a new [`Action`] with the given [`Operation`].
pub fn new(operation: impl Operation<T> + 'static) -> Self {
Self(Box::new(operation))
}
/// Maps the output of an [`Action`] using the given function.
pub fn map<A>(
self,
f: impl Fn(T) -> A + 'static + MaybeSend + Sync,
@ -24,11 +28,13 @@ impl<T> Action<T> {
}))
}
/// Consumes the [`Action`] and returns the internal [`Operation`].
pub fn into_operation(self) -> Box<dyn Operation<T>> {
self.0
}
}
#[allow(missing_debug_implementations)]
struct Map<A, B> {
operation: Box<dyn Operation<A>>,
f: Box<dyn Fn(A) -> B>,