Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. use std::fmt::Debug;
  2. use std::cell::RefCell;
  3. use std::rc::Rc;
  4. use std::any::Any;
  5.  
  6. pub trait ScalarType: Debug {}
  7.  
  8. pub trait AttributeType: Debug {}
  9. impl<T> AttributeType for T where T: ScalarType {}
  10. impl<T> AttributeType for (T, T) where T: ScalarType {}
  11.  
  12. #[derive(Debug)]
  13. pub struct Attribute<T> where T: AttributeType + 'static {
  14. value: RefCell<T>,
  15. name: String,
  16. }
  17.  
  18. trait Attributing: Debug {
  19.  
  20. type Inner;
  21.  
  22. fn get_value(&self) -> &Self::Inner;
  23. fn set_value(&mut self, value: Self::Inner);
  24.  
  25. fn into_any_rc(self: Rc<Self>) -> Rc<dyn Any>;
  26.  
  27. }
  28.  
  29. impl<T> Attributing for Attribute<T> where T: AttributeType {
  30.  
  31. type Inner = T;
  32.  
  33. fn get_value(&self) -> &T {
  34. unimplemented!()
  35. }
  36. fn set_value(&mut self, value: T) {
  37. unimplemented!()
  38. }
  39. fn into_any_rc(self: Rc<Self>) -> Rc<dyn Any> {
  40. self
  41. }
  42. }
  43.  
  44. fn main() { }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement