diff --git a/activitystreams-derive/src/lib.rs b/activitystreams-derive/src/lib.rs index 345a471..76a497d 100644 --- a/activitystreams-derive/src/lib.rs +++ b/activitystreams-derive/src/lib.rs @@ -142,14 +142,22 @@ pub fn ref_derive(input: TokenStream) -> TokenStream { let name = name.clone(); let ext_trait = Ident::new(&format!("{}Ext", object), name.span()); + let tt = if object.to_string() == "Object" || object.to_string() == "Link" { + quote! { + #[typetag::serde] + } + } else { + quote! {} + }; + let activity_impls = quote! { - #[typetag::serde] + #tt impl #object for #name { - fn as_any(&self) -> &std::any::Any { + fn as_any(&self) -> &dyn std::any::Any { self } - fn as_any_mut(&self) -> &mut std::any::Any { + fn as_any_mut(&self) -> &mut dyn std::any::Any { self } } diff --git a/activitystreams-types/src/object/properties.rs b/activitystreams-types/src/object/properties.rs index 2db4dbd..95a0186 100644 --- a/activitystreams-types/src/object/properties.rs +++ b/activitystreams-types/src/object/properties.rs @@ -25,6 +25,7 @@ //! use activitystreams_traits::Object; //! use activitystreams_types::object::properties::ObjectProperties; //! use serde_derive::{Deserialize, Serialize}; +//! use std::any::Any; //! //! #[derive(Clone, Debug, Serialize, Deserialize)] //! #[serde(rename_all = "camelCase")] @@ -39,7 +40,15 @@ //! pub object_properties: ObjectProperties, //! } //! -//! impl Object for MyObject {} +//! impl Object for MyObject { +//! fn as_any(&self) -> &dyn Any { +//! self +//! } +//! +//! fn as_any_mut(&mut self) -> &mut dyn Any { +//! self +//! } +//! } //! # //! # fn main() {} //! ```