From 7e8ee5ed9cad6484e9f13f81731b102ced58402e Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Tue, 9 Jul 2019 15:14:04 -0400 Subject: Init. --- rust-book/crates/src/lib.rs | 33 +++++++++++++++++++++++++++++++++ rust-book/crates/src/main.rs | 8 ++++++++ 2 files changed, 41 insertions(+) create mode 100755 rust-book/crates/src/lib.rs create mode 100755 rust-book/crates/src/main.rs (limited to 'rust-book/crates/src') diff --git a/rust-book/crates/src/lib.rs b/rust-book/crates/src/lib.rs new file mode 100755 index 0000000..5cf1d97 --- /dev/null +++ b/rust-book/crates/src/lib.rs @@ -0,0 +1,33 @@ +//! # Art +//! +//! A library for modeling artistic concepts. + +pub use kinds::PrimaryColor; +pub use kinds::SecondaryColor; +pub use utils::mix; + +pub mod kinds { + /// The primary colors according to the RYB color model. + pub enum PrimaryColor { + Red, + Yellow, + Blue, + } + + /// The secondary colors according to the RYB color model. + pub enum SecondaryColor { + Orange, + Green, + Purple, + } +} + +pub mod utils { + use crate::kinds::*; + + /// Combines two primary color in equal amounts to create + /// a secondary color. + pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor { + SecondaryColor::Green + } +} diff --git a/rust-book/crates/src/main.rs b/rust-book/crates/src/main.rs new file mode 100755 index 0000000..80668f2 --- /dev/null +++ b/rust-book/crates/src/main.rs @@ -0,0 +1,8 @@ +use art::PrimaryColor; +use art::mix; + +fn main() { + let red = PrimaryColor::Red, + let yellow = PrimaryColor::Yellow; + mix(red, yellow); +} -- cgit v1.2.3