Idiomatic futures-locks


Ladies and Gentleman,

I would like to spawn asynchronous futures that store their results in a mutex provided by futures-locks crate. I can process the futures asynchronously but saving the result to a mutex is my difficulty. The following MCVE involves my strategy of running fut1 and somehow passing the result to fut2 where it can be stored in mutex but is this an idiomatic approach for storing async processes into a mutex? Thank you most excellent Rust community!

extern crate futures;
extern crate futures_locks;
extern crate tokio;
extern crate tokio_process;

use futures::Future;
use std::process::Command;
use std::time::Duration;
use tokio::prelude::*;
use tokio_process::CommandExt;

fn main() {
    let cmds = vec!["", "", ""]
        .map(|x| vec![format!("ping -c 2 {}", x), format!("dig {}", x)].join(";"))
    let mutex = futures_locks::Mutex::<Vec<_>>::new(vec![]);
    let clone0 = mutex.clone();
    let parent = stream::iter_ok(cmds).for_each(move |cmd| {
        let fut1 = Command::new("bash")
            .map_err(|e| println!("failed to collect output: {}", e))
            .map(|i| {
                // Pass this value to fut2 somehow?
                // Is this idiomatic strategy?

        // fut2 can save to mutex
        let fut2 = clone0.lock().map(move |mut guard| guard.push(cmd));
    // Need result of fut1 available here