diff options
author | Adam Carpenter <gitlab@53hor.net> | 2019-07-09 15:14:04 -0400 |
---|---|---|
committer | Adam Carpenter <gitlab@53hor.net> | 2019-07-09 15:14:04 -0400 |
commit | 7e8ee5ed9cad6484e9f13f81731b102ced58402e (patch) | |
tree | 5395402ab07bbb5a659dbd68c701e22a1227202f /rust-book/crates | |
download | learning-rust-7e8ee5ed9cad6484e9f13f81731b102ced58402e.tar.xz learning-rust-7e8ee5ed9cad6484e9f13f81731b102ced58402e.zip |
Init.
Diffstat (limited to 'rust-book/crates')
-rwxr-xr-x | rust-book/crates/Cargo.lock | 4 | ||||
-rwxr-xr-x | rust-book/crates/Cargo.toml | 7 | ||||
-rwxr-xr-x | rust-book/crates/src/lib.rs | 33 | ||||
-rwxr-xr-x | rust-book/crates/src/main.rs | 8 |
4 files changed, 52 insertions, 0 deletions
diff --git a/rust-book/crates/Cargo.lock b/rust-book/crates/Cargo.lock new file mode 100755 index 0000000..3e95fa1 --- /dev/null +++ b/rust-book/crates/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "crates" +version = "0.1.0" + diff --git a/rust-book/crates/Cargo.toml b/rust-book/crates/Cargo.toml new file mode 100755 index 0000000..202ff1d --- /dev/null +++ b/rust-book/crates/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "crates" +version = "0.1.0" +authors = ["53hornet <53hornet@gmail.com>"] +edition = "2018" + +[dependencies] 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); +} |