Rust Getting Started to Mastery (Part 3) - Different Strings
Category: C/C++2024-07-10 15:08:57
Preface
For developers who have just switched to Rust from Java, Golang, etc., the various types of strings in Rust are dazzling. Among them, one of the most confusing issues is the concept of string and slice (str).
In languages like Java and Golang, we only have one concept string albania whatsapp number data 5 million data type, String. Unfortunately, in Rust, we have about 6 concepts related to string data types. This article attempts to sort out in depth what the differences are between these "strings" to help Rust beginners (MiTu) understand and use them properly.
First of all, let's make it clear that there is only one string type in the Rust core language, namely the string slice str, which is essentially an array slice [u8] that satisfies the UTF-8 encoding and is a collection of characters stored somewhere in memory.
This involves arrays and slices. So,
Arrays, dynamic arrays, slices
Array[T]
Fixed Size: An array is a fixed-size data structure, once declared, its size cannot be changed.
Let's start with Rust's arrays (mutable arrays) and slices
-
- Posts: 36
- Joined: Tue Dec 10, 2024 3:20 am