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

run doc test for impl FromIterator for TextArea

Этот коммит содержится в:
rhysd
2023-11-19 22:18:21 +09:00
родитель 9e3df38b54
Коммит a9d981f2d8

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

@@ -131,16 +131,19 @@ where
/// Collect line texts from iterator as [`TextArea`]. It is useful when creating a textarea with text read from a file. /// Collect line texts from iterator as [`TextArea`]. It is useful when creating a textarea with text read from a file.
/// [`Iterator::collect`] handles errors which may happen on reading each lines. The following example reads text from /// [`Iterator::collect`] handles errors which may happen on reading each lines. The following example reads text from
/// a file efficiently line-by-line. /// a file efficiently line-by-line.
/// ```no_run /// ```
/// use std::fs; /// use std::fs;
/// use std::io::{self, BufRead}; /// use std::io::{self, BufRead};
/// use std::path::Path; /// use std::path::Path;
/// use tui_textarea::TextArea; /// use tui_textarea::TextArea;
/// ///
/// fn read_from_file<'a>(path: impl AsRef<Path>) -> io::Result<TextArea<'a>> { /// fn read_from_file<'a>(path: impl AsRef<Path>) -> io::Result<TextArea<'a>> {
/// let file = fs::File::open(path.as_ref())?; /// let file = fs::File::open(path)?;
/// io::BufReader::new(file).lines().collect() /// io::BufReader::new(file).lines().collect()
/// } /// }
///
/// let textarea = read_from_file("README.md").unwrap();
/// assert!(!textarea.is_empty());
/// ``` /// ```
impl<'a, S: Into<String>> FromIterator<S> for TextArea<'a> { impl<'a, S: Into<String>> FromIterator<S> for TextArea<'a> {
fn from_iter<I: IntoIterator<Item = S>>(iter: I) -> Self { fn from_iter<I: IntoIterator<Item = S>>(iter: I) -> Self {