Files
RustPython/derive/src/pyvalue.rs
2021-09-24 20:41:11 +09:00

19 lines
521 B
Rust

use super::Diagnostic;
use proc_macro2::TokenStream;
use quote::quote;
use syn::DeriveInput;
pub(crate) fn impl_pyvalue(input: DeriveInput) -> std::result::Result<TokenStream, Diagnostic> {
let ty = &input.ident;
let ret = quote! {
impl ::rustpython_vm::PyValue for #ty {
fn class(_vm: &::rustpython_vm::VirtualMachine) -> &rustpython_vm::builtins::PyTypeRef {
use ::rustpython_vm::StaticType;
Self::static_type()
}
}
};
Ok(ret)
}