lex-lib 0.3.2

Contains simple but usefull stuff for Rust development.
Documentation
//! Vector2 generic.

/// Generic Vector2.
///
/// Requires for the Type to derive `Debug, Clone, PartialEq` and implement `Default` trait
///
/// Doesn't overload operators like the other Vector2s
#[derive(Debug, Clone, PartialEq)]
pub struct Vec2generic<T>{
	/// X value.
	pub x: T,
	/// Y value.
	pub y: T
}

impl<T: Clone> Vec2generic<T>{
	/// Creates a new [`Vec2generic`] with x and y defined.
	///
	/// use `default()` for a default initialized.
	pub fn new(x: T, y: T) -> Self {
		Self{
			x,
			y
		}
	}
	
	/// Puts x into y and y into x
	pub fn flip(&mut self){
		let tmp = self.x.clone();
		self.x = self.y.clone();
		self.y = tmp;
	}
}

impl<T: Default> Default for Vec2generic<T> {
	/// Creates a new [`Vec2generic`] with x and y initialized with the Type default.
	fn default() -> Self {
		Self{
			x: T::default(),
			y: T::default()
		}
	}
}