#unwrap_or_else error
7 messages · Page 1 of 1 (latest)
i'd recommend assigning some things to intermediate variables rather than making one big statement. It might help if the types are more obvious
Ah, then yeah, it's that unwrap_or_else doesn't support awaiting through it
You can use match, though
let amount = get_activity(req, page, contract_address, token_id)
.await?
.results
.iter()
.find_map(|action| (action.kind == "sale") //renamed this to workaround the bug in syntax highlighting
.then_some(action.value.amount.parse::<u64>().unwrap());
Ok(match amount {
Some(x) => x,
None => super::collections::get_stats(req, contract_address, rtype).await.unwrap().floor_price_in_cents,
})
Basically, just write the impl of unwrap_or_else