mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-08 04:36:49 +01:00
Compare commits
No commits in common. "8bfd1a23a1f880a1d2fb104a158fc51f244acd6e" and "bad20f5037dc22d572a8381840fab871ce65f565" have entirely different histories.
8bfd1a23a1
...
bad20f5037
4 changed files with 15 additions and 24 deletions
|
|
@ -5,17 +5,3 @@ pub type Usually<T> = Result<T, Box<dyn Error>>;
|
|||
|
||||
/// Standard optional result type.
|
||||
pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
|
||||
|
||||
/// Implement the `From` trait.
|
||||
#[macro_export] macro_rules! from {
|
||||
($(<$($lt:lifetime),+>)?|$state:ident:$Source:ty|$Target:ty=$cb:expr) => {
|
||||
impl $(<$($lt),+>)? From<$Source> for $Target {
|
||||
fn from ($state:$Source) -> Self { $cb }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub trait Has<T>: Send + Sync {
|
||||
fn get (&self) -> &T;
|
||||
fn get_mut (&mut self) -> &mut T;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,17 +3,13 @@ use std::sync::{Arc, atomic::{AtomicUsize, Ordering::Relaxed}};
|
|||
|
||||
pub trait HasSize<E: Output> {
|
||||
fn size (&self) -> &Measure<E>;
|
||||
fn width (&self) -> usize {
|
||||
self.size().w()
|
||||
}
|
||||
fn height (&self) -> usize {
|
||||
self.size().w()
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Output, T: Has<Measure<E>>> HasSize<E> for T {
|
||||
fn size (&self) -> &Measure<E> {
|
||||
self.get()
|
||||
#[macro_export] macro_rules! has_size {
|
||||
(<$E:ty>|$self:ident:$Struct:ident$(<$($L:lifetime),*$($T:ident$(:$U:path)?),*>)?|$cb:expr) => {
|
||||
impl $(<$($L),*$($T $(: $U)?),*>)? HasSize<$E> for $Struct $(<$($L),*$($T),*>)? {
|
||||
fn size (&$self) -> &Measure<$E> { $cb }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@ impl ToTokens for CommandDef {
|
|||
fn get <'source> (&self, iter: &mut ::tengri::dsl::TokenIter<'source>)
|
||||
-> Option<#enumeration>
|
||||
{
|
||||
use ::tengri::dsl::TryFromDsl;
|
||||
#enumeration::try_from_expr(self, iter)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,16 @@ pub use ::ratatui; pub(crate) use ratatui::{
|
|||
|
||||
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicBool, Ordering::*}};
|
||||
pub(crate) use std::io::{stdout, Stdout};
|
||||
pub(crate) use std::path::PathBuf;
|
||||
pub(crate) use std::ffi::OsString;
|
||||
|
||||
#[macro_export] macro_rules! from {
|
||||
($(<$($lt:lifetime),+>)?|$state:ident:$Source:ty|$Target:ty=$cb:expr) => {
|
||||
impl $(<$($lt),+>)? From<$Source> for $Target {
|
||||
fn from ($state:$Source) -> Self { $cb }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)] #[test] fn test_tui_engine () -> Usually<()> {
|
||||
use crate::*;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue