Commit e948443d authored by Luke Jones's avatar Luke Jones

Make struct members private

parent eb78a0f0
Pipeline #63287793 passed with stages
in 4 minutes and 50 seconds
[package]
name = "vec2d"
version = "0.3.3"
version = "0.4.0"
authors = ["Luke Jones <luke@sphereidentity.com>"]
edition = "2018"
......
......@@ -3,14 +3,14 @@ use num_traits::float::Float;
use std::convert::From;
use std::ops::{
Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign, Rem,
Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign
};
/// Representation of a mathematical vector e.g. a position or velocity
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Default)]
pub struct Vec2d<T> {
pub x: T,
pub y: T,
x: T,
y: T,
}
macro_rules! impl_vec_ops_for {
......@@ -71,6 +71,34 @@ impl<T> Vec2d<T> {
T: Float {
Vec2d { x: x, y: y }
}
#[inline]
pub fn x(&self) -> T
where
T: Float {
self.x
}
#[inline]
pub fn set_x(&mut self, x: T)
where
T: Float {
self.x = x
}
#[inline]
pub fn y(&self) -> T
where
T: Float {
self.y
}
#[inline]
pub fn set_y(&mut self, y: T)
where
T: Float {
self.y = y
}
}
/// Add scalar to `Vec2d`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment