Focus mode
Since having a memory management feature in Rust, there are 2 separate string types, one of which takes the letters as a vector and the other as a whole. In this way, we have the chance to manage the modifiable and non-modifiable partitions.
In performance-oriented languages, memory usage is minimized by reducing unnecessary storage. Data types such as String cause unnecessary memory usage as they freely use the Heap structure in all languages. For this reason, it is preferred to keep the events in the stack in rust and Heap is used when really necessary.
We can use &str to point to a specific part of an existing String instead of creating new String structures standing in the Heap. In this way, it does not require any allocation at runtime, and fixed-length &str cannot be resized.
You can find detailed further information from Rust Official documentation:
https://doc.rust-lang.org/book/ch04-03-slices.html
Resources:
https://www.tutorialspoint.com/rust/rust_slices.htm
https://www.educative.io/answers/what-is-the-slice-type-in-rust
Programs to Accelerate Your Progress in a Software Career
Join our 4-8 month intensive Patika+ bootcamps, start with the fundamentals and gain comprehensive knowledge to kickstart your software career!
You need to enroll in the course to be able to comment!