Guest User

Untitled

a guest
Jun 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. use std::ops::*;
  2.  
  3. pub trait Num:
  4. Copy
  5. + Sized
  6. + Mul<Output=Self>
  7. + Add<Output=Self>
  8. + Into<f64>
  9. {
  10. }
  11.  
  12. struct Vec3 {
  13. x: f64,
  14. y: f64,
  15. z: f64,
  16. }
  17.  
  18. impl <S: Num> Vec3 {
  19. fn new(x: S, y: S, z: S) -> Vec3 {
  20. Vec3{
  21. x: x.into(),
  22. y: y.into(),
  23. z: z.into(),
  24. }
  25. }
  26. }
  27.  
  28. fn main() {
  29. let _ = Vec3::new(1, 1, 2);
  30. }
Add Comment
Please, Sign In to add comment