This commit is contained in:
🪞👃🪞 2025-05-14 17:59:06 +03:00
parent d7bbc2a412
commit e3a3962130
15 changed files with 74 additions and 81 deletions

View file

@ -9,24 +9,19 @@ pub(crate) use std::sync::{Arc, atomic::{AtomicUsize, AtomicBool, Ordering::Rela
pub(crate) use std::fmt::Debug;
pub(crate) use std::ops::{Add, Sub, Mul, Div, Rem};
pub(crate) use ::tengri::{from, Usually, Perhaps, tui::*};
pub(crate) use ::tengri::{from, Usually, Perhaps, Has, tui::*};
pub use ::atomic_float; pub(crate) use atomic_float::*;
pub trait Has<T>: Send + Sync {
fn get (&self) -> &T;
fn get_mut (&mut self) -> &mut T;
}
//pub trait MaybeHas<T>: Send + Sync {
//fn get (&self) -> Option<&T>;
//}
pub trait MaybeHas<T>: Send + Sync {
fn get (&self) -> Option<&T>;
}
impl<T, U: Has<Option<T>>> MaybeHas<T> for U {
fn get (&self) -> Option<&T> {
Has::<Option<T>>::get(self).as_ref()
}
}
//impl<T, U: Has<Option<T>>> MaybeHas<T> for U {
//fn get (&self) -> Option<&T> {
//Has::<Option<T>>::get(self).as_ref()
//}
//}
#[macro_export] macro_rules! has {
($T:ty: |$self:ident : $S:ty| $x:expr) => {