Code review

The preceding code is somewhat different from the code in previous examples where we have simply used to_owned() to convert the slice to a string. We now have to create a mutable string and assign to that rather than just add to the end of full_line as we did previously.

The reason is that the slice being converted to string is not mutable; therefore, the type created will also be non-mutable. Since you cannot add to a non-mutable variable, we could not use the push and push_str methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset