How to output stream content?

Example code as following:

I impl encodable trait for Account, and want to print the stream content.
something wrong happened while compiling. i am confused about this.

impl rlp::Encodable for Account {
    fn rlp_append(&self, s: &mut rlp::RlpStream) {
         println!("s output: {:?}", s.out());

The compiler conplained:

32 |         println!("s output: {:?}", s.out());
   |                                    ^ cannot move out of borrowed content

How can i get the stream content output?

It looks like out takes rlp::RlpStream by value, bit you only have a mutable reference. So you could swap out the value behind the reference with some dummy data using std::mem::replace, then call out on that.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.