coreyja @coreyja.com · Dec 11

#Rustlang Tip: ✅ DO: use &str for string slices and String for owned strings. ❌ DON'T: use &String as a function parameter. #Rust30x30

3 likes 1 replies

?

Replies

coreyja · Dec 11

Why? Using &str is more flexible: 1: It allows passing &str and &String as arguments. 2: It's more flexible as it can be used to pass string literals and string slices. 3: It clearly communicates that the function won't modify the string.