1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-07 16:05:50 +03:00

implement FromIterator for TextArea

Этот коммит содержится в:
rhysd
2022-06-14 22:15:38 +09:00
родитель c1598c5600
Коммит c019f10431
2 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@@ -161,6 +161,14 @@ let mut text: String = ...;
let mut textarea = TextARea::from(text.lines());
```
`TextArea` also implements `FromIterator<impl Into<String>>`. `Iterator::collect()` can collect strings as an editor
instance. This allows to create `TextArea` reading lines from file efficiently using `io::BufReader`.
```rust
let file = fs::File::open(path)?;
let mut textarea: TextArea = io::BufReader::new(file).lines().collect::<io::Result<_>>()?;
```
### Get text contents from `TextArea`
`TextArea::lines()` returns text lines as `&[String]`. It borrows text contents temporarily.