> For the complete documentation index, see [llms.txt](https://rust-book.dewaka.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rust-book.dewaka.com/text-processing/string-to-vecs.md).

# Converting a string to vectors and back

## How to convert a String to a vector of chars?

```rust
let s = "Hello there";

// Convert a string to a Vec<char>
let cvec: Vec<char> = s.chars().collect();
```

## How to convert vector of chars back to a String?

Carrying from the above example,

```rust
// Convert a string to a Vec<char>
let cvec: Vec<char> = s.chars().collect();

// Convert a Vec<char> into a String
let back: String = cvec.into_iter().collect();
```
