官术网_书友最值得收藏!

  • 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.

主站蜘蛛池模板: 武威市| 枞阳县| 新宾| 尼玛县| 兴仁县| 浠水县| 体育| 平顶山市| 大城县| 遵义市| 望都县| 聊城市| 五原县| 平邑县| 南岸区| 鹤庆县| 高尔夫| 资源县| 江西省| 绥阳县| 五家渠市| 平南县| 邻水| 襄城县| 榆树市| 望城县| 济源市| 海门市| 从化市| 淳化县| 桦甸市| 凉山| 九龙城区| 黑水县| 黄龙县| 皋兰县| 绵竹市| 海宁市| 镇赉县| 融水| 怀集县|