feat(document): plumb in an optional file name

This commit is contained in:
Harsh Shandilya 2022-08-08 00:31:53 +05:30
parent 15c874a2e3
commit 5ea82d6a71
No known key found for this signature in database
GPG Key ID: 366D7BBAD1031E80

View File

@ -4,6 +4,7 @@ use std::fs;
#[derive(Default)]
pub struct Document {
rows: Vec<Row>,
pub file_name: Option<String>,
}
impl Document {
@ -25,6 +26,9 @@ impl Document {
for line in contents.lines() {
rows.push(Row::from(line));
}
Ok(Self { rows })
Ok(Self {
rows,
file_name: Some(filename.to_string()),
})
}
}