Reworked imports

This commit is contained in:
Rico Riedel 2022-08-01 15:58:07 +02:00
parent 38bf1818e4
commit ba68f5e11e
No known key found for this signature in database
GPG Key ID: 75AC868575DE7B18
12 changed files with 54 additions and 58 deletions

View File

@ -1,9 +1,10 @@
use crate::convert::char::{CharConverter, CharSample}; mod char;
use crate::convert::color::ColorConverter; mod color;
use crossterm::style::Color;
pub mod char; pub use crate::convert::char::*;
pub mod color; pub use crate::convert::color::*;
use crossterm::style::Color;
#[cfg_attr(test, mockall::automock)] #[cfg_attr(test, mockall::automock)]
pub trait Converter { pub trait Converter {
@ -30,8 +31,8 @@ impl<T1: CharConverter, T2: ColorConverter> Converter for ConverterImpl<T1, T2>
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::convert::char::MockCharConverter; use crate::convert::MockCharConverter;
use crate::convert::color::MockColorConverter; use crate::convert::MockColorConverter;
use mockall::predicate::*; use mockall::predicate::*;
#[test] #[test]

View File

@ -1,11 +1,20 @@
pub mod convert; pub mod convert;
pub mod error;
pub mod pattern; pub mod pattern;
pub mod printer;
mod error;
mod printer;
mod renderer; mod renderer;
pub mod term; mod term;
mod timer;
mod vec; mod vec;
fn main() -> Result<(), error::Error> { pub use error::*;
pub use printer::*;
pub use renderer::*;
pub use term::*;
pub use timer::*;
pub use vec::*;
fn main() -> Result<(), Error> {
Ok(()) Ok(())
} }

View File

@ -1,5 +1,5 @@
use crate::pattern::{Config, Pattern, PatternFactory}; use crate::pattern::*;
use crate::vec::Vector; use crate::Vector;
#[derive(Default)] #[derive(Default)]
pub struct CircleFactory; pub struct CircleFactory;

View File

@ -1,5 +1,5 @@
use crate::pattern::{Config, Pattern, PatternFactory}; use crate::pattern::*;
use crate::vec::Vector; use crate::Vector;
#[derive(Default)] #[derive(Default)]
pub struct LineFactory; pub struct LineFactory;

View File

@ -1,9 +1,14 @@
pub mod circle; mod circle;
pub mod line; mod line;
pub mod rhombus; mod rhombus;
pub mod wheel; mod wheel;
use crate::vec::Vector; pub use circle::*;
pub use line::*;
pub use rhombus::*;
pub use wheel::*;
use crate::Vector;
#[derive(Copy, Clone, PartialEq, Debug)] #[derive(Copy, Clone, PartialEq, Debug)]
pub struct Config { pub struct Config {

View File

@ -1,5 +1,5 @@
use crate::pattern::{Config, Pattern, PatternFactory}; use crate::pattern::*;
use crate::vec::Vector; use crate::Vector;
#[derive(Default)] #[derive(Default)]
pub struct RhombusFactory; pub struct RhombusFactory;

View File

@ -1,5 +1,5 @@
use crate::pattern::{Config, Pattern, PatternFactory}; use crate::pattern::*;
use crate::vec::Vector; use crate::Vector;
use std::f32::consts::PI; use std::f32::consts::PI;
#[derive(Default)] #[derive(Default)]

View File

@ -1,5 +1,5 @@
use crate::error::Error; use crate::Error;
use crate::term::Terminal; use crate::Terminal;
use crossterm::cursor::*; use crossterm::cursor::*;
use crossterm::style::*; use crossterm::style::*;
use crossterm::terminal::*; use crossterm::terminal::*;
@ -96,7 +96,7 @@ impl<T: Terminal> Printer for PrinterImpl<T> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::term::MockTerminal; use crate::MockTerminal;
use mockall::predicate::eq; use mockall::predicate::eq;
#[test] #[test]

View File

@ -1,9 +1,8 @@
use crate::convert::char::CharSample; use crate::convert::{CharSample, Converter};
use crate::convert::Converter; use crate::pattern::*;
use crate::error::Error; use crate::Error;
use crate::pattern::{Config, Sampler, SamplerFactory}; use crate::Printer;
use crate::printer::Printer; use crate::Vector;
use crate::vec::Vector;
#[cfg_attr(test, mockall::automock)] #[cfg_attr(test, mockall::automock)]
pub trait Renderer { pub trait Renderer {
@ -69,7 +68,7 @@ mod test {
use crate::convert::MockConverter; use crate::convert::MockConverter;
use crate::pattern::MockSampler; use crate::pattern::MockSampler;
use crate::pattern::MockSamplerFactory; use crate::pattern::MockSamplerFactory;
use crate::printer::MockPrinter; use crate::MockPrinter;
use crossterm::style::Color; use crossterm::style::Color;
use mockall::predicate::eq; use mockall::predicate::eq;
use mockall::Sequence; use mockall::Sequence;

View File

@ -1,4 +1,4 @@
use crate::error::Error; use crate::Error;
use crossterm::{Command, QueueableCommand}; use crossterm::{Command, QueueableCommand};
use std::io::Write; use std::io::Write;

View File

@ -1,5 +1,5 @@
use crate::error::Error; use crate::Error;
use crate::renderer::Renderer; use crate::Renderer;
use std::thread; use std::thread;
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
@ -58,7 +58,7 @@ impl<T: Clock> Timer<T> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::renderer::MockRenderer; use crate::MockRenderer;
use mockall::predicate::eq; use mockall::predicate::eq;
use mockall::Sequence; use mockall::Sequence;

View File

@ -1,6 +1,4 @@
use std::ops::Sub; #[derive(Copy, Clone, PartialEq, Debug, Default, derive_more::Sub)]
#[derive(Copy, Clone, PartialEq, Debug, Default)]
pub struct Vector { pub struct Vector {
pub x: f32, pub x: f32,
pub y: f32, pub y: f32,
@ -36,14 +34,6 @@ impl Vector {
} }
} }
impl Sub for Vector {
type Output = Vector;
fn sub(self, rhs: Self) -> Self::Output {
Self::new(self.x - rhs.x, self.y - rhs.y)
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
@ -80,12 +70,4 @@ mod test {
fn angle() { fn angle() {
assert_abs_diff_eq!(-1.5, Vector::new(2.0, -20.0).angle(), epsilon = 0.1); assert_abs_diff_eq!(-1.5, Vector::new(2.0, -20.0).angle(), epsilon = 0.1);
} }
#[test]
fn sub() {
assert_eq!(
Vector::new(-5.0, 10.0),
Vector::new(3.0, 16.0) - Vector::new(8.0, 6.0)
);
}
} }