move processors into const

This commit is contained in:
Jake Howard 2017-09-06 19:42:46 +01:00
parent 8603dbcc77
commit d4e46c3090
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 8 additions and 5 deletions

View file

@ -1,13 +1,10 @@
use config::Config;
use processors::html_cleanup::html_cleanup;
use processors::strip_blank::strip_blank;
use processors::PROCESSORS;
pub fn render(config: Config, input: String) -> Result<String, String> {
let mut rendered_input = input;
let renderers: Vec<fn(Config, String) -> Result<String, String>> =
vec![html_cleanup, strip_blank];
for renderer in renderers {
for renderer in PROCESSORS.into_iter() {
rendered_input = try!(renderer(config.clone(), rendered_input));
}
return Ok(rendered_input);

View file

@ -1,2 +1,8 @@
use config::Config;
pub mod html_cleanup;
pub mod strip_blank;
pub const PROCESSORS: [fn(Config, String) -> Result<String, String>; 2] =
[html_cleanup::html_cleanup, strip_blank::strip_blank];