mirror of
https://github.com/ricoriedel/wipe.git
synced 2024-11-04 23:26:41 +00:00
Reworked imports
This commit is contained in:
parent
38bf1818e4
commit
ba68f5e11e
@ -1,9 +1,10 @@
|
||||
use crate::convert::char::{CharConverter, CharSample};
|
||||
use crate::convert::color::ColorConverter;
|
||||
use crossterm::style::Color;
|
||||
mod char;
|
||||
mod color;
|
||||
|
||||
pub mod char;
|
||||
pub mod color;
|
||||
pub use crate::convert::char::*;
|
||||
pub use crate::convert::color::*;
|
||||
|
||||
use crossterm::style::Color;
|
||||
|
||||
#[cfg_attr(test, mockall::automock)]
|
||||
pub trait Converter {
|
||||
@ -30,8 +31,8 @@ impl<T1: CharConverter, T2: ColorConverter> Converter for ConverterImpl<T1, T2>
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::convert::char::MockCharConverter;
|
||||
use crate::convert::color::MockColorConverter;
|
||||
use crate::convert::MockCharConverter;
|
||||
use crate::convert::MockColorConverter;
|
||||
use mockall::predicate::*;
|
||||
|
||||
#[test]
|
||||
|
17
src/main.rs
17
src/main.rs
@ -1,11 +1,20 @@
|
||||
pub mod convert;
|
||||
pub mod error;
|
||||
pub mod pattern;
|
||||
pub mod printer;
|
||||
|
||||
mod error;
|
||||
mod printer;
|
||||
mod renderer;
|
||||
pub mod term;
|
||||
mod term;
|
||||
mod timer;
|
||||
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(())
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::pattern::{Config, Pattern, PatternFactory};
|
||||
use crate::vec::Vector;
|
||||
use crate::pattern::*;
|
||||
use crate::Vector;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct CircleFactory;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::pattern::{Config, Pattern, PatternFactory};
|
||||
use crate::vec::Vector;
|
||||
use crate::pattern::*;
|
||||
use crate::Vector;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct LineFactory;
|
||||
|
@ -1,9 +1,14 @@
|
||||
pub mod circle;
|
||||
pub mod line;
|
||||
pub mod rhombus;
|
||||
pub mod wheel;
|
||||
mod circle;
|
||||
mod line;
|
||||
mod rhombus;
|
||||
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)]
|
||||
pub struct Config {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::pattern::{Config, Pattern, PatternFactory};
|
||||
use crate::vec::Vector;
|
||||
use crate::pattern::*;
|
||||
use crate::Vector;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct RhombusFactory;
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::pattern::{Config, Pattern, PatternFactory};
|
||||
use crate::vec::Vector;
|
||||
use crate::pattern::*;
|
||||
use crate::Vector;
|
||||
use std::f32::consts::PI;
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::error::Error;
|
||||
use crate::term::Terminal;
|
||||
use crate::Error;
|
||||
use crate::Terminal;
|
||||
use crossterm::cursor::*;
|
||||
use crossterm::style::*;
|
||||
use crossterm::terminal::*;
|
||||
@ -96,7 +96,7 @@ impl<T: Terminal> Printer for PrinterImpl<T> {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::term::MockTerminal;
|
||||
use crate::MockTerminal;
|
||||
use mockall::predicate::eq;
|
||||
|
||||
#[test]
|
||||
|
@ -1,9 +1,8 @@
|
||||
use crate::convert::char::CharSample;
|
||||
use crate::convert::Converter;
|
||||
use crate::error::Error;
|
||||
use crate::pattern::{Config, Sampler, SamplerFactory};
|
||||
use crate::printer::Printer;
|
||||
use crate::vec::Vector;
|
||||
use crate::convert::{CharSample, Converter};
|
||||
use crate::pattern::*;
|
||||
use crate::Error;
|
||||
use crate::Printer;
|
||||
use crate::Vector;
|
||||
|
||||
#[cfg_attr(test, mockall::automock)]
|
||||
pub trait Renderer {
|
||||
@ -69,7 +68,7 @@ mod test {
|
||||
use crate::convert::MockConverter;
|
||||
use crate::pattern::MockSampler;
|
||||
use crate::pattern::MockSamplerFactory;
|
||||
use crate::printer::MockPrinter;
|
||||
use crate::MockPrinter;
|
||||
use crossterm::style::Color;
|
||||
use mockall::predicate::eq;
|
||||
use mockall::Sequence;
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::error::Error;
|
||||
use crate::Error;
|
||||
use crossterm::{Command, QueueableCommand};
|
||||
use std::io::Write;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
use crate::error::Error;
|
||||
use crate::renderer::Renderer;
|
||||
use crate::Error;
|
||||
use crate::Renderer;
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
@ -58,7 +58,7 @@ impl<T: Clock> Timer<T> {
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::renderer::MockRenderer;
|
||||
use crate::MockRenderer;
|
||||
use mockall::predicate::eq;
|
||||
use mockall::Sequence;
|
||||
|
||||
|
20
src/vec.rs
20
src/vec.rs
@ -1,6 +1,4 @@
|
||||
use std::ops::Sub;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug, Default)]
|
||||
#[derive(Copy, Clone, PartialEq, Debug, Default, derive_more::Sub)]
|
||||
pub struct Vector {
|
||||
pub x: 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)]
|
||||
mod test {
|
||||
use super::*;
|
||||
@ -80,12 +70,4 @@ mod test {
|
||||
fn angle() {
|
||||
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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user