When would an implementation want to take ownership of self in Rust?

前端 未结 2 1345
感动是毒
感动是毒 2021-01-05 04:57

I\'m reading through the Rust documentation on lifetimes. I tried something like:

struct S {
    x: i8,
}

impl S {
    fn fun(self) {}

    fn print(&se         


        
2条回答
  •  爱一瞬间的悲伤
    2021-01-05 05:17

    Conversion from type A to type B commonly involves functions taking self by value. See the implementors of Into and From traits for concrete examples.

提交回复
热议问题