pub type Boolean = bool;
pub type Number = f64;
pub type String = std::string::String;
pub type Array<T> = std::vec::Vec<T>;
pub type Promise<T> = std::result::Result<T, anyhow::Error>;
pub type Void = ();
pub mod promise {
use super::Promise;
pub fn resolve<T>(val: T) -> Promise<T> {
Ok(val)
}
pub fn reject<T>(err: impl AsRef<str>) -> Promise<T> {
Err(anyhow::anyhow!(err.as_ref().to_string()))
}
}
pub struct Nullable<T> {
val: Option<T>,
}
impl<T> Nullable<T> {
pub fn new(val: Option<T>) -> Self {
Nullable { val }
}
pub fn some(val: T) -> Self {
Nullable { val: Some(val) }
}
pub fn none() -> Self {
Nullable { val: None }
}
pub fn value(mut self, val: T) -> Self {
self.val = Some(val);
self
}
pub fn value_of(&self) -> Option<&T> {
self.val.as_ref()
}
pub fn into_value(self) -> Option<T> {
self.val
}
}