首页 文章

我可以使用像值传递的可变引用方法吗?

提问于
浏览
1

我可以使用像值传递的可变引用方法吗?例如,我可以使用

o.mth(&mut self, ...)

o.mth(self, ...)

这将允许我返回结果而不用担心 o 的生命周期 . 它可能涉及 move 闭包,或某种包装?

对于上下文,我'm trying to return a boxed iterator over CSV records using the rust-csv package but the iterator can'比读者活得更长,Reader::records(&'t mut self)可以接受 . 与BufRead::lines(self)相比,它消耗了它的读卡器,因此可以在没有生命周期问题的情况下返回 .

1 回答

相关问题