Skip to content

Commit

Permalink
run doc test for impl FromIterator for TextArea
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Nov 19, 2023
1 parent 9e3df38 commit a9d981f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/textarea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
/// [`Iterator::collect`] handles errors which may happen on reading each lines. The following example reads text from
/// a file efficiently line-by-line.
/// ```no_run
/// ```
/// use std::fs;
/// use std::io::{self, BufRead};
/// use std::path::Path;
/// use tui_textarea::TextArea;
///
/// 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()
/// }
///
/// let textarea = read_from_file("README.md").unwrap();
/// assert!(!textarea.is_empty());
/// ```
impl<'a, S: Into<String>> FromIterator<S> for TextArea<'a> {
fn from_iter<I: IntoIterator<Item = S>>(iter: I) -> Self {
Expand Down

0 comments on commit a9d981f

Please sign in to comment.