1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::{Location, Object};

pub enum BorderType {
    Simple,
}

pub fn ascii_for_border_or(
    object: &dyn Object,
    location: &Location,
    border_type: BorderType,
    default: impl Fn() -> Option<char>,
) -> Option<char> {
    match border_type {
        BorderType::Simple => {
            if object.is_top_left_corner(location) {
                Some('┌')
            } else if object.is_top_right_corner(location) {
                Some('┐')
            } else if object.is_bottom_left_corner(location) {
                Some('└')
            } else if object.is_bottom_right_corner(location) {
                Some('┘')
            } else if object.is_right_boundary(location) || object.is_left_boundary(location) {
                Some('│')
            } else if object.is_top_boundary(location) || object.is_bottom_boundary(location) {
                Some('─')
            } else {
                default()
            }
        }
    }
}