[go: up one dir, main page]

Macro border

Source
macro_rules! border {
    () => { ... };
    ($b:ident) => { ... };
    ($first:ident,$($other:ident),*) => { ... };
}
Expand description

Macro that constructs and returns a combination of the Borders object from TOP, BOTTOM, LEFT and RIGHT.

When used with NONE you should consider omitting this completely. For ALL you should consider Block::bordered() instead.

ยงExamples

use ratatui::{
    border,
    widgets::{Block, Borders},
};

Block::new()
    .title("Construct Borders and use them in place")
    .borders(border!(TOP, BOTTOM));

border! can be called with any number of individual sides:

use ratatui::{border, widgets::Borders};
let right_open = border!(TOP, LEFT, BOTTOM);
assert_eq!(right_open, Borders::TOP | Borders::LEFT | Borders::BOTTOM);

Single borders work but using Borders:: directly would be simpler.

use ratatui::{border, widgets::Borders};

assert_eq!(border!(TOP), Borders::TOP);
assert_eq!(border!(ALL), Borders::ALL);
assert_eq!(border!(), Borders::NONE);