From 695dd38e08526ea0123788887073e650667c0290 Mon Sep 17 00:00:00 2001 From: Cutieguwu Date: Mon, 23 Sep 2024 11:10:19 -0400 Subject: [PATCH] Initial commit --- .gitignore | 1 + Cargo.lock | 7 ++ Cargo.toml | 6 ++ README.adoc | 37 +++++++++++ src/main.rs | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 231 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 README.adoc create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a1486c8 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "building_up" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..3b5c068 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "building_up" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..640fae7 --- /dev/null +++ b/README.adoc @@ -0,0 +1,37 @@ +:source-highlighter: highlight.js +:highlightjs-languages: rust, swift +:toc: auto + += Falling Down & Rising Up + + +== *Falling Down* + +[%hardbreaks] +Growing up too fast, +I'm the top of my class, +no time to have a blast, +pushed for an A pass. + + +Lazy results in inefficiency, +so Einstein becomes a lumberjack. +Pushed for proficiency, +of all trades; I am Jack. + + +What lies behind my youthful laughter, +but all those disguised implications, +causing so many a lost chapter, +why come now these new revelations? + + +My mind becomes fore frantic, +perhaps I must `panic!("Help me...)` + + +== *Building Up* + +../src/main.rs + +[source, rust] +---- +include::./src/main.rs[] +---- diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..6ee2ef3 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,180 @@ +use std::process::{ExitCode, Termination}; + +fn main() -> Result { + let mut me = Me { + state: Emotion::Panic + }; + + // From the dark and desperate, I must rise up + me = me.rise_up(); + + /* + My hope may not shimmer like a diamond, + I may hate myself, + though what is for sure, + but my persistance to perfect; + + start(); + + My perfection which causes burnout so, + may it be fueled by hearty maple, + may it shimmer and glow, + my kindling give way to something stable; + */ + + let mut persistant = true; + + while persistant { + let _x = match me + .clone() + .try_one() { + Result::Ok(_) => break, + Result::Err(x) => x + }; + + // Spring of will own + + let _x = match me + .clone() + .try_two(){ + Result::Ok(_) => break, + Result::Err(x) => x + }; + + // Summer's final chance + + me = match me.try_final() { + Result::Ok(x) => x, + Result::Err(_) => panic!("Gone, gone are the coals which gave me life.") + }; + + persistant = false + }; + + /* + Seasons know their persistant cycle, + give each other the will to live, + give care to group survival, + seasons thrive; + + The cycle will endure, + each error corrected, + each hole patched; + + Let Autumn and Winter clean the parasites; + Let Spring bring rejuvenation; + Let Summer be my contribution and thanks; + */ + + // Let the cycle keep me + Ok(Emotion::Safe) + // At last +} + +#[derive(Clone)] +struct Me { + state: Emotion +} + +impl Me { + fn rise_up(mut self) -> Self { + /* + wait..., + but how do I do that?..., + for I am + */ + + self.state; + + /* + I must believe, + [I know this sounds like a cat poster, but it's true], + I must be + */ + + self.state = Emotion::Hopeful; + + self + } + + fn try_one(mut self) -> Result<(), &'static str> { + /* + Autumn come too late, + must fell those branches of parasite ridden leaves, + must outlast that cold great, + Autumn leads, upheaves; + */ + + self.state = Emotion::Desperate; + + /* + Winter come, + by blind hand snowstorm cast, + by mind numb, + Winter snow blast; + */ + + Err("Rage, Rage against the dying of my flame;") + } + + fn try_two(mut self) -> Result<(), &'static str> { + self.state = Emotion::Depressed; + + /* + Spring brings remorse, + melt away the snowmen sank, + melt away all ice forts in course, + Spring's flowers, rivers drank; + */ + + Err("By charcoal hot, I can rise;") + } + + fn try_final(mut self) -> Result { + /* + Spring's cleaning not wasted, + clean out the closet, + clean grief once basted, + Spring's soul a prophet; + */ + + self.state = Emotion::Hopeful; + + /* + Summer flowers, + showing their petals to the gleaming sun, + showing their strength against the showers, + Summer begun; + */ + + self.state = Emotion::Happy; + + Ok(self) + } +} + +#[derive(Clone)] +enum Emotion { + Panic, + Hopeful, + Desperate, + Depressed, + Happy, + Safe +} + +impl Termination for Emotion { + fn report(self) -> std::process::ExitCode { + ExitCode::SUCCESS + } +} + +#[derive(Debug)] +struct Impossible; + +impl Termination for Impossible { + fn report(self) -> std::process::ExitCode { + // I cannot fail now. + ExitCode::SUCCESS + } +} \ No newline at end of file