Initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/target
|
||||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@@ -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"
|
||||||
6
Cargo.toml
Normal file
6
Cargo.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "building_up"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
37
README.adoc
Normal file
37
README.adoc
Normal file
@@ -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[]
|
||||||
|
----
|
||||||
180
src/main.rs
Normal file
180
src/main.rs
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
use std::process::{ExitCode, Termination};
|
||||||
|
|
||||||
|
fn main() -> Result<Emotion, Impossible> {
|
||||||
|
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<Self, ()> {
|
||||||
|
/*
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user