leetcode_tui_core/
lib.rs

1pub mod event;
2pub mod step;
3pub use event::Event;
4use std::error::Error;
5pub mod content;
6pub mod errors;
7pub mod help;
8pub mod input;
9pub mod popup;
10pub mod progress;
11pub mod utils;
12
13pub type UBStrSender = tokio::sync::mpsc::UnboundedSender<Option<String>>;
14
15pub trait SendError<T, E> {
16    fn emit_if_error(self) -> Result<T, E>;
17}
18
19impl<T, E> SendError<T, E> for Result<T, E>
20where
21    E: Error + Sized,
22{
23    fn emit_if_error(self) -> Result<T, E> {
24        match self {
25            Err(e) => {
26                emit!(Error(e.to_string()));
27                Err(e)
28            }
29            ok => ok,
30        }
31    }
32}
33
34pub fn init() {
35    content::question::init();
36}