diff --git a/src/ch09-03-strings.md b/src/ch09-03-strings.md index 8092843..7fafd0b 100644 --- a/src/ch09-03-strings.md +++ b/src/ch09-03-strings.md @@ -3,16 +3,27 @@ We've already talked about strings a bunch in chapter four, but let's take a more in-depth look at them now. -## creating +## Creating +You can create an empty string with `new`: +```rust +let s = String::new(); +``` -new, String::from and .to_string() +Often, you have some initial data that you'd like to start the string off with. +For that, there's the `.to_string()` method: -## reading +```rust +let data = "initial contents"; + +let s = data.to_string(); +``` + +## Reading slicing syntax, indexing -## updating +## Updating push_str, concatenation