pub trait Connectors {
const LAST: &'static str;
const GAP: &'static str;
}
pub trait TreeConnectors: Connectors {
const BRANCH: &'static str;
const VERT: &'static str;
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Unicode;
impl Connectors for Unicode {
const LAST: &'static str = "└─ ";
const GAP: &'static str = " ";
}
impl TreeConnectors for Unicode {
const BRANCH: &'static str = "├─ ";
const VERT: &'static str = "│ ";
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Ascii;
impl Connectors for Ascii {
const LAST: &'static str = "`- ";
const GAP: &'static str = " ";
}
impl TreeConnectors for Ascii {
const BRANCH: &'static str = "|- ";
const VERT: &'static str = "| ";
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_unicode_glyphs() {
assert_eq!(Unicode::BRANCH, "├─ ");
assert_eq!(Unicode::LAST, "└─ ");
assert_eq!(Unicode::VERT, "│ ");
assert_eq!(Unicode::GAP, " ");
}
#[test]
fn test_ascii_glyphs() {
assert_eq!(Ascii::BRANCH, "|- ");
assert_eq!(Ascii::LAST, "`- ");
assert_eq!(Ascii::VERT, "| ");
assert_eq!(Ascii::GAP, " ");
}
}