l_system_fractals/lib.rs
1// src/lib.rs
2//
3// This file is part of l-system-fractals
4//
5// Copyright 2024 Christopher Phan
6//
7// See README.md in repository root directory for copyright/license info
8//
9// SPDX-License-Identifier: MIT OR Apache-2.0
10//
11#![warn(missing_docs)]
12
13//! A command-line utility (and library) for creating
14//! [L-system](https://en.wikipedia.org/wiki/L-system) fractals.
15//!
16//! - Author: [Christopher Phan](https://chrisphan.com/)
17//! - Git repository: [on Codeberg](https://codeberg.org/christopherphan/l-systems-fractals-rust/)
18//! - License: [MIT](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/LICENSE-MIT.txt) or
19//! [Apache 2.0](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/LICENSE-APACHE-2.0.txt)
20//! - [`crates.io` page](https://crates.io/crates/l-system-fractals)
21//! - [`docs.rs` page](https://docs.rs/l-system-fractals/latest/l_system_fractals/)
22//!
23//! # Installation
24//!
25//! First, if needed, [install the latest version of Rust](https://www.rust-lang.org/tools/install).
26//! Then, run from the command line:
27//!
28//! ```console
29//! $ cargo install l-system-fractals
30//! ```
31//!
32//! # Command line use
33//!
34//! ```console
35//! $ l-system-fractals filename.json
36//! ```
37//!
38//! For detailed information on how to create the JSON input file, see the file
39//! `cli_help.md`
40//! ([rendered on
41//! Codeberg](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/cli_help.md))
42//! in the repository root directory.
43//!
44//! ## Examples
45//!
46//! - [Examples](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/examples/README.md)
47//!
48//! # Copyright
49//!
50//! Copyright © 2024 Christopher Phan
51//!
52//! Available under either the
53//! [MIT](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/LICENSE-MIT.txt) or
54//! [Apache
55//! 2.0](https://codeberg.org/christopherphan/l-systems-fractals-rust/src/branch/main/LICENSE-APACHE-2.0.txt)
56//! license.
57//!
58//! # Credits
59//!
60//! ## Serde JSON
61//!
62//! This project uses the [Serde JSON](https://crates.io/crates/serde_json) library, which is used
63//! under both the MIT and Apache 2.0 licenses.
64pub mod errors;
65pub mod num_validity;
66pub mod parse_files;
67pub mod paths;
68pub mod rules;
69
70mod misc {
71 // used only in testing
72 #[allow(dead_code)]
73 pub fn logical_xor(a: bool, b: bool) -> bool {
74 a && !b || !a && b
75 }
76
77 #[cfg(test)]
78 mod tests {
79 use super::*;
80
81 #[test]
82 fn test_logical_xor() {
83 assert!(!logical_xor(false, false));
84 assert!(!logical_xor(true, true));
85 assert!(logical_xor(true, false));
86 assert!(logical_xor(false, true));
87 }
88 }
89}