Rust Tutorial Chapter 4 - Delving into String and Ownership


foreword

The catalog of this series of tutorials can be viewed here: Rust Tutorial Catalog

The previous chapters introduced many of the basic basic data structures in Rust, and Stringthis type is often used because it is related to a core concept in Rust: ownership

Therefore, it has not been answered before, and the purpose of this article is to delve into the Stringunderlying principles of this, and use it as a medium to introduce the concept of ownership

1. String analysis

Looking at the software you often come into contact with from a more macro perspective, you can find that for console programs, you only see characters

For software with a graphical interface (GUI), in addition to patterns, there are various texts (strings)

From this you can see the importance of strings: no matter what program, the use of strings is basically inseparable

To use strings in rust, you can use the following code:

fn 

Guess you like

Origin blog.csdn.net/weixin_50964512/article/details/130179038