2019-05-01 20:34:24 +00:00
|
|
|
use super::{Context, Module};
|
2020-07-07 22:45:32 +00:00
|
|
|
use crate::segment::Segment;
|
2019-04-05 00:33:36 +00:00
|
|
|
|
2019-07-19 20:18:52 +00:00
|
|
|
/// Creates a module for the line break
|
2019-07-02 20:12:53 +00:00
|
|
|
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
2019-04-05 00:33:36 +00:00
|
|
|
const LINE_ENDING: &str = "\n";
|
|
|
|
|
2019-09-09 23:14:38 +00:00
|
|
|
let mut module = context.new_module("line_break");
|
2019-04-12 23:11:40 +00:00
|
|
|
|
2020-08-17 02:16:05 +00:00
|
|
|
module.set_segments(vec![Segment::new(None, LINE_ENDING)]);
|
2019-05-01 20:34:24 +00:00
|
|
|
|
|
|
|
Some(module)
|
2019-04-05 00:33:36 +00:00
|
|
|
}
|
2020-09-21 17:06:15 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
|
|
|
use std::io;
|
|
|
|
|
|
|
|
use crate::test::ModuleRenderer;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn produces_result() -> io::Result<()> {
|
|
|
|
let expected = Some(String::from("\n"));
|
|
|
|
let actual = ModuleRenderer::new("line_break").collect();
|
|
|
|
assert_eq!(expected, actual);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|