midenc_hir/attributes/attribute/
value.rs1use core::clone::CloneToUninit;
2
3use crate::any::AsAny;
4
5pub trait AttributeValue: AsAny + CloneToUninit {}
6
7impl<T: AsAny + CloneToUninit> AttributeValue for T {}
8
9impl dyn AttributeValue {
10 pub fn is<T: AsAny>(&self) -> bool {
12 self.as_any().is::<T>()
13 }
14
15 pub fn downcast_ref<T: AsAny>(&self) -> Option<&T> {
17 self.as_any().downcast_ref::<T>()
18 }
19
20 pub fn downcast_mut<T: AsAny>(&mut self) -> Option<&mut T> {
25 self.as_any_mut().downcast_mut::<T>()
26 }
27}