Could methods of the Any trait object be generalized?

Could the methods of std::any::Any be soundly generalized like this?

pub fn is<U: Any + ?Sized, T: Any>(this: &U) -> bool;
pub fn downcast_ref<U: Any + ?Sized, T: Any>(this: &U) -> Option<&T>;
pub fn downcast_mut<U: Any + ?Sized, T: Any>(this: &mut U) -> Option<&mut T>;

The main motivation is to allow the downcast methods to be used on other traits that have Any as a supertrait, without the need for workarounds such as

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.