Skip to main content

fn_reflection/
lib.rs

1//! # Art
2//!
3//! A library for modeling artistic concepts.
4
5pub use kinds::PrimaryColor; // 再exportによりクレートユーザーが階層構造を意識せずにenumを利用できる
6pub use kinds::SecondaryColor;
7pub use utils::mix;
8
9pub mod kinds {
10    /// The primary colors according to the RYB color model.
11    pub enum PrimaryColor { Red, Yellow, Blue }
12    /// The secondary colors according to the RYB color model.
13    pub enum SecondaryColor { Orange, Green, Purple }
14}
15
16pub mod utils {
17    use crate::kinds::*;
18    /// Combines two primary colors in equal amounts to create a secondary color.
19    pub fn mix(c1: PrimaryColor, c2: PrimaryColor) -> SecondaryColor {
20        SecondaryColor::Orange
21    }
22}
23
24/// ## Semantics
25/// Adds one to the given number.
26/// ## Examples
27/// 
28/// ```
29/// let five = 5;
30/// assert_eq!(6, fn-reflection::add_one(5));
31///``````
32pub fn add_one(x: i32) -> i32 {
33    x + 1
34}