1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-17 02:25:17 +00:00
starship/src/modules/line_break.rs

30 lines
656 B
Rust
Raw Normal View History

2019-05-01 20:34:24 +00:00
use super::{Context, Module};
use crate::segment::Segment;
2019-04-05 00:33:36 +00:00
/// Creates a module for the line break
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
2019-04-05 00:33:36 +00:00
const LINE_ENDING: &str = "\n";
let mut module = context.new_module("line_break");
2019-04-12 23:11:40 +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
}
#[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(())
}
}