- Learning Rust
- Paul Johnson Vesa Kaihlavirta
- 90字
- 2021-07-02 23:07:17
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.
推薦閱讀
- Unity 2020 By Example
- Advanced Quantitative Finance with C++
- HTML5+CSS3+JavaScript從入門到精通:上冊(微課精編版·第2版)
- Spring技術內幕:深入解析Spring架構與設計
- Learning RxJava
- HTML5 移動Web開發從入門到精通(微課精編版)
- 精通API架構:設計、運維與演進
- Java Web應用開發技術與案例教程(第2版)
- jQuery開發基礎教程
- JavaScript入門經典
- BIM概論及Revit精講
- Multithreading in C# 5.0 Cookbook
- 匯編語言編程基礎:基于LoongArch
- Practical Microservices
- Java Web開發教程:基于Struts2+Hibernate+Spring