In this video, we are going to explore the difference between String and &str in Rust, as well as different tips to use them.

Topics:

  • 00:00 Introduction
  • 00:44 Strings in memory
  • 01:30 Trim operation
  • 02:00 Trim in Rust
  • 02:34 &str
  • 02:48 When an allocation is needed
  • 03:25 String literals
  • 04:04 String vs &str
  • 05:14 Converting between String and &str
  • 05:39 Strings in function signatures
  • 06:17 Conclusion

#rust

Understanding Strings in Rust - String vs &str
14.00 GEEK