chore: allow Buffer::with_lines to accept IntoIterator (#901)
This can make it easier to use `Buffer::with_lines` with iterators that don't necessarily produce a `Vec`. For example, this allows using `Buffer::with_lines` with `&[&str]` directly, without having to call `collect` on it first.
This commit is contained in:
@@ -71,9 +71,10 @@ impl Buffer {
|
||||
}
|
||||
|
||||
/// Returns a Buffer containing the given lines
|
||||
pub fn with_lines<'a, S>(lines: Vec<S>) -> Buffer
|
||||
pub fn with_lines<'a, Iter>(lines: Iter) -> Buffer
|
||||
where
|
||||
S: Into<Line<'a>>,
|
||||
Iter: IntoIterator,
|
||||
Iter::Item: Into<Line<'a>>,
|
||||
{
|
||||
let lines = lines.into_iter().map(Into::into).collect::<Vec<_>>();
|
||||
let height = lines.len() as u16;
|
||||
|
||||
Reference in New Issue
Block a user