Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::ops::*;
- pub trait Num:
- Copy
- + Sized
- + Mul<Output=Self>
- + Add<Output=Self>
- + Into<f64>
- {
- }
- struct Vec3 {
- x: f64,
- y: f64,
- z: f64,
- }
- impl <S: Num> Vec3 {
- fn new(x: S, y: S, z: S) -> Vec3 {
- Vec3{
- x: x.into(),
- y: y.into(),
- z: z.into(),
- }
- }
- }
- fn main() {
- let _ = Vec3::new(1, 1, 2);
- }
Add Comment
Please, Sign In to add comment