Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. pub trait Engine {}
  2.  
  3. pub trait GpuEngine: Engine {}
  4.  
  5.  
  6. pub struct MyEngine {}
  7. impl Engine for MyEngine {}
  8. impl GpuEngine for MyEngine {}
  9.  
  10.  
  11. pub struct OtherEngine {}
  12. impl Engine for OtherEngine {}
  13.  
  14. #[cfg(not(eature = "gpu-engine"))]
  15. pub fn use_engine(engine: impl Engine) {
  16. // do sth cool with that engine
  17. }
  18.  
  19. #[cfg(feature = "gpu-engine")]
  20. pub fn use_engine(engine: impl GpuEngine) {
  21. // do sth cool with that gpu engine
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement