我尝试解压缩嵌套元组并使用组合子来完成:
let create_task = |msg| {
// We need to keep the message_id to report failures to SQS
// and the receipt_handle to delete the processed messages from SQS.
let SqsMessageObj {
message_id,
body,
receipt_handle,
..
} = msg;
let span = tracing::span!(tracing::Level::INFO, "Handling SQS msg", message_id);
let task = async {
let item = serde_json::from_value(body)?;
f(item, app_config).await
};
(
(
message_id.unwrap_or_default(),
receipt_handle.unwrap_or_default(),
),
task,
)
};
print!("{:?}", event.payload);
let ((ids, receipts), tasks): ((_, _), _) = event
.payload
.records
.into_iter()
.map(create_task)
.unzip::<(_, _), _, (_, _), _>();
编译器对此不满意。unzip()类型的注解应该是什么?
1条答案
按热度按时间vfh0ocws1#
这是通过对所有元组元素使用
Vec<_>
类型来完成的: