use crate::*;
use std::fmt::Debug;
pub trait Handle: Clone + Default + TryAdopt
{
fn spawn<R, F>(&self, task: F) -> PendingResult<R>
where
R: Debug + Send + Sync + 'static,
F: std::future::Future<Output = R> + Send + 'static;
}
pub trait TryAdopt: Sized
{
fn try_adopt() -> Option<Self>;
}
pub trait AdoptOrDefault: TryAdopt + Default
{
fn adopt_or_default() -> Self
{
if let Some(adoptee) = Self::try_adopt() { return adoptee; }
Self::default()
}
}
impl<T: TryAdopt + Default> AdoptOrDefault for T {}