SHARE
TWEET

Untitled

a guest Apr 18th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top