// Helper that adapts existing functions with a signature like `Root::broadcast_into`
// into a Broadcast impl, given the existence of a `Default` impl.
Helper that adapts existing functions with a signature like `Root::broadcast_into`
into a Broadcast impl, given the existence of a `Default` impl.
Helper that adapts existing functions with a signature like ` Root :: broadcast_into ` into a Broadcast impl given the existence of a ` Default ` impl .
fn broadcast_via_mut_ref<T, R>(
    root: &R,
    value: Option<T>,
    broadcast_into: impl FnOnce(&R, &mut T),
) -> T
where
    R: mpi::AsCommunicator + mpi::Root,
    T: Default,
{
    if this_process_is_root(root) && value.is_none() {
        panic!("root did not provide value to broadcast");
    }
    let mut buf = value.unwrap_or_else(Default::default);
    broadcast_into(root, &mut buf);
    buf
}
fn broadcast_via_mut_ref < T , R > ( root : & R , value : Option < T > , broadcast_into : impl FnOnce ( & R , & mut T ) , ) -> T where R : mpi :: AsCommunicator + mpi :: Root , T : Default , { if this_process_is_root ( root ) && value . is_none ( ) { panic ! ( " " ) ; } let mut buf = value . unwrap_or_else ( Default :: default ) ; broadcast_into ( root , & mut buf ) ; buf }
Helper that adapts existing functions with a signature like `Root::broadcast_into`
into a Broadcast impl, given the existence of a `Default` impl.
Helper that adapts existing functions with a signature like ` Root :: broadcast_into ` into a Broadcast impl given the existence of a ` Default ` impl .
root
&R
value
Option<T>
broadcast_into
impl FnOnce(&R, &mut T)