pub async fn fold(
        self,
        txn: Txn,
        item_name: Id,
        mut state: Map<State>,
        op: Closure,
    ) -> TCResult<State> {
        let mut source = self.into_stream(txn.clone()).await?;

        while let Some(item) = source.try_next().await? {
            let mut args = state.clone();
            args.insert(item_name.clone(), item);
            let result = op.clone().call(&txn, args.into()).await?;
            state = result.try_into()?;
        }

        Ok(State::Map(state))
    }
/// Fold this stream with the given initial `State` and `Closure`.
///
/// For example, folding `[1, 2, 3]` with `0` and `Number::add` will produce `6`.
Fold this stream with the given initial `State` and `Closure`.
Fold this stream with the given initial ` State ` and ` Closure ` .
pub async fn fold(
        self,
        txn: Txn,
        item_name: Id,
        mut state: Map<State>,
        op: Closure,
    ) -> TCResult<State> {
        let mut source = self.into_stream(txn.clone()).await?;
        while let Some(item) = source.try_next().await? {
            let mut args = state.clone();
            args.insert(item_name.clone(), item);
            let result = op.clone().call(&txn, args.into()).await?;
            state = result.try_into()?;
        }
        Ok(State::Map(state))
    }
pub async fn fold ( self , txn : Txn , item_name : Id , mut state : Map < State > , op : Closure , ) -> TCResult < State > { let mut source = self . into_stream ( txn . clone ( ) ) . await ? ; while let Some ( item ) = source . try_next ( ) . await ? { let mut args = state . clone ( ) ; args . insert ( item_name . clone ( ) , item ) ; let result = op . clone ( ) . call ( & txn , args . into ( ) ) . await ? ; state = result . try_into ( ) ? ; } Ok ( State :: Map ( state ) ) }
Fold this stream with the given initial `State` and `Closure`.
Fold this stream with the given initial ` State ` and ` Closure ` .
self
txn
Txn
item_name
Id
state
Map<State>
op
Closure
self
txn
Txn
item_name
Id
state
Map<State>
op
Closure