diff options
author | Gaurav <allmanpride@gmail.com> | 2022-08-14 02:00:41 +0000 |
---|---|---|
committer | Gaurav <allmanpride@gmail.com> | 2022-08-14 02:00:41 +0000 |
commit | ebf5337ff1075aa9138f9d02ab9c52af41c8890b (patch) | |
tree | 098c95a97b7cd25f770c6f33bc202fa6c3f694b0 /src/listing.rs | |
parent | Make Readme struct (diff) | |
download | miniserve-ebf5337ff1075aa9138f9d02ab9c52af41c8890b.tar.gz miniserve-ebf5337ff1075aa9138f9d02ab9c52af41c8890b.zip |
Edit Readme struct to remove render bool
Diffstat (limited to '')
-rw-r--r-- | src/listing.rs | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/src/listing.rs b/src/listing.rs index 3a54118..6f9e485 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -149,22 +149,12 @@ impl Breadcrumb { /// Readme file information pub struct Readme { - pub render: bool, - pub path: Option<PathBuf>, - pub filename: Option<String>, - pub contents: Option<String>, + pub path: PathBuf, + pub filename: String, + pub contents: String, } impl Readme { - fn blank() -> Self { - Readme { - render: false, - path: None, - filename: None, - contents: None, - } - } - fn new(root: PathBuf, base: &Path, filename: String) -> Self { let file_path = root .canonicalize() @@ -183,10 +173,9 @@ impl Readme { &ComrakOptions::default(), ); Readme { - render: true, - path: Some(file_path), - filename: Some(filename), - contents: Some(contents), + path: file_path, + filename, + contents, } } } @@ -277,7 +266,7 @@ pub fn directory_listing( } let mut entries: Vec<Entry> = Vec::new(); - let mut readme = Readme::blank(); + let mut readme: Option<Readme> = None; for entry in dir.path.read_dir()? { if dir.is_visible(&entry) || conf.show_hidden { @@ -329,7 +318,7 @@ pub fn directory_listing( symlink_dest, )); if conf.readme && file_name.to_lowercase() == "readme.md" { - readme = Readme::new(conf.path.clone(), base, file_name) + readme = Some(Readme::new(conf.path.clone(), base, file_name)); } } } else { |