Fix clippy errors
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
use crate::prelude::*;
|
||||
|
||||
mod window;
|
||||
|
||||
pub trait Application {
|
||||
type Output;
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
pub mod application;
|
||||
pub mod window;
|
||||
@@ -9,8 +9,8 @@ pub struct Window {
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub const fn new() -> Window {
|
||||
Window {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
dimensions: Vec2::new(0, 0),
|
||||
position: Vec2::new(0, 0),
|
||||
bordered: true,
|
||||
@@ -19,32 +19,32 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_bordered(&self) -> bool {
|
||||
pub const fn is_bordered(&self) -> bool {
|
||||
self.bordered
|
||||
}
|
||||
|
||||
pub fn is_open(&self) -> bool {
|
||||
pub const fn is_open(&self) -> bool {
|
||||
self.opened
|
||||
}
|
||||
|
||||
pub fn open(&mut self) {
|
||||
pub const fn open(&mut self) {
|
||||
self.opened = true;
|
||||
}
|
||||
|
||||
pub fn close(&mut self) {
|
||||
pub const fn close(&mut self) {
|
||||
self.opened = false;
|
||||
}
|
||||
|
||||
// some basic getters and setters for utility.
|
||||
pub fn title(&self) -> &str {
|
||||
&self.title
|
||||
pub fn title(&'static self) -> &'static str {
|
||||
self.title.as_str()
|
||||
}
|
||||
|
||||
pub fn dimensions(&self) -> Vec2<usize> {
|
||||
pub const fn dimensions(&self) -> Vec2<usize> {
|
||||
self.dimensions
|
||||
}
|
||||
|
||||
pub fn position(&self) -> Vec2<usize> {
|
||||
pub const fn position(&self) -> Vec2<usize> {
|
||||
self.position
|
||||
}
|
||||
|
||||
@@ -56,15 +56,21 @@ impl Window {
|
||||
self.position += offset;
|
||||
}
|
||||
|
||||
pub fn set_position(&mut self, position: Vec2<usize>) {
|
||||
pub const fn set_position(&mut self, position: Vec2<usize>) {
|
||||
self.position = position;
|
||||
}
|
||||
|
||||
pub fn set_dimensions(&mut self, dimensions: Vec2<usize>) {
|
||||
pub const fn set_dimensions(&mut self, dimensions: Vec2<usize>) {
|
||||
self.dimensions = dimensions;
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Window {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Window {
|
||||
fn drop(&mut self) {
|
||||
if self.opened {
|
||||
|
||||
@@ -20,7 +20,7 @@ impl Coordinate for i128 {}
|
||||
impl Coordinate for f32 {}
|
||||
impl Coordinate for f64 {}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Debug)]
|
||||
pub struct Vec2<T: Coordinate> {
|
||||
x: T,
|
||||
y: T,
|
||||
@@ -32,14 +32,14 @@ impl<T: Coordinate> Vec2<T> {
|
||||
}
|
||||
|
||||
pub fn into<S: Coordinate + From<T>>(&self) -> Vec2<S> {
|
||||
Vec2::new(self.x.clone().into(), self.y.clone().into())
|
||||
Vec2::new(self.x.into(), self.y.into())
|
||||
}
|
||||
|
||||
pub fn x(&self) -> T {
|
||||
pub const fn x(&self) -> T {
|
||||
self.x
|
||||
}
|
||||
|
||||
pub fn y(&self) -> T {
|
||||
pub const fn y(&self) -> T {
|
||||
self.y
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user