allow converting Box<dyn RRData> to Box<dyn Any> for owned downcast

This commit is contained in:
Stefan Bühler 2020-03-07 19:05:00 +01:00
parent 7aeeec9f97
commit ff13630b8c
3 changed files with 10 additions and 0 deletions

View File

@ -117,4 +117,8 @@ impl RRData for UnknownRecord {
fn as_any(&self) -> &dyn ::std::any::Any {
self as _
}
fn as_box_any(self: Box<Self>) -> Box<dyn ::std::any::Any> {
self as _
}
}

View File

@ -108,6 +108,8 @@ pub trait RRData: RRDataPacket + RRDataText + fmt::Debug + 'static {
fn as_any(&self) -> &dyn Any;
fn as_box_any(self: Box<Self>) -> Box<dyn Any>;
// (type, rrdata)
fn text(&self) -> Result<(String, String)> {
let mut buf = String::new();

View File

@ -66,6 +66,10 @@ pub fn rrdata_derive(s: synstructure::Structure) -> proc_macro2::TokenStream {
fn as_any(&self) -> &::std::any::Any {
self as _
}
fn as_box_any(self: Box<Self>) -> Box<dyn ::std::any::Any> {
self as _
}
},
);