use crate::obj::prelude::*; use std::{any::Any, sync::LazyLock}; pub static NONE_INST: LazyLock = LazyLock::new(|| ObjPtr::new(None::new())); static NONE_STR: LazyLock = LazyLock::new(|| ObjPtr::new(Str::new("None"))); static NONE_ATTRS: LazyLock = LazyLock::new(|| { attrs_ptr! { // "__str__" => builtin_fun_ptr!("__str__", |_vm, args, _state| { if args.len() != 1 { todo!("Throw exception: arity error"); } BuiltinFunResult::Return(Some(ObjPtr::clone(&NONE_STR))) }), } }); #[derive(Debug)] pub struct None { attrs: AttrsPtr, } impl None { fn new() -> Self { let attrs = AttrsPtr::clone(&NONE_ATTRS); Self { attrs } } } impl Obj for None { fn attrs(&self) -> AttrsPtr { AttrsPtr::clone(&self.attrs) } fn as_any(&self) -> &(dyn Any + 'static) { self } }