1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// src/lib.rs
//
// This file is part of l-system-fractals
//
// Copyright 2024 Christopher Phan
//
// See README.md in repository root directory for copyright/license info
//
// SPDX-License-Identifier: MIT OR Apache-2.0
//
#![warn(missing_docs)]

//! A command-line utility (and library) for creating
//! [L-system](https://en.wikipedia.org/wiki/L-system) fractals.
//!
//! - Author: [Christopher Phan](https://chrisphan.com/)
//! - Git repository: [on Codeberg](https://codeberg.org/christopherphan/l-systems-fractals-rust/)
//! - License: [MIT](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/LICENSE-MIT.txt) or
//!   [Apache 2.0](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/LICENSE-APACHE-2.0.txt)
//! - [`crates.io` page](https://crates.io/crates/l-system-fractals)
//! - [`docs.rs` page](https://docs.rs/l-system-fractals/latest/l_system_fractals/)
//!
//! # Installation
//!
//! First, if needed, [install the latest version of Rust](https://www.rust-lang.org/tools/install).
//! Then, run from the command line:
//!
//! ```console
//! $ cargo install l-system-fractals
//! ```
//!
//! # Command line use
//!
//! ```console
//! $ l-system-fractals filename.json
//! ```
//!
//! For detailed information on how to create the JSON input file, see the file
//! `cli_help.md`
//! ([rendered on
//! Codeberg](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/cli_help.md))
//! in the repository root directory.
//!
//! ## Examples
//!
//! - [Examples](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/examples/README.md)
//!
//! # Copyright
//!
//! Copyright © 2024 Christopher Phan
//!
//! Available under either the
//! [MIT](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/LICENSE-MIT.txt) or
//! [Apache
//! 2.0](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/LICENSE-APACHE-2.0.txt)
//! license.
//!
//! # Credits
//!
//! ## Serde JSON
//!
//! This project uses the [Serde JSON](https://crates.io/crates/serde_json) library, which is used
//! under both the MIT and Apache 2.0 licenses.
pub mod errors;
pub mod num_validity;
pub mod parse_files;
pub mod paths;
pub mod rules;

mod misc {
    // used only in testing
    #[allow(dead_code)]
    pub fn logical_xor(a: bool, b: bool) -> bool {
        a && !b || !a && b
    }

    #[cfg(test)]
    mod tests {
        use super::*;

        #[test]
        fn test_logical_xor() {
            assert!(!logical_xor(false, false));
            assert!(!logical_xor(true, true));
            assert!(logical_xor(true, false));
            assert!(logical_xor(false, true));
        }
    }
}