Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. use std::collections::BTreeMap;
  2.  
  3. struct World {
  4. entities: Vec<usize>,
  5. //database: BTreeMap<usize, Box<ReadValue>>,
  6. database: BTreeMap<usize, Box<ReadEcs<T = SourceInputGateway>>>, // Doesn't work
  7. }
  8.  
  9. struct SourceInputGateway {
  10. entity_id: usize,
  11. }
  12.  
  13. trait ReadValue {
  14. fn read(&self) -> f32;
  15. }
  16.  
  17. impl ReadValue for SourceInputGateway {
  18. fn read(&self) -> f32 {
  19. 0.0
  20. }
  21. }
  22.  
  23. trait ReadEcs {
  24. type T;
  25. fn read(&self) -> &Self::T;
  26. }
  27.  
  28. impl ReadEcs for SourceInputGateway {
  29. type T = SourceInputGateway;
  30. fn read(&self) -> &Self::T {
  31. self
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement