esoteric_vm/machine/
omega.rs

1//! An esoteric type.
2//!
3//! For more information, read the docs for [`Ω`].
4
5use std::io::{self, Write};
6
7/// An esoteric type
8#[derive(Debug, Clone)]
9pub struct Ω {
10    /// The illusion of choice.
11    ///
12    /// Highlights how ZSTs tend to be useless.
13    pub illusion_of_choice: Option<Option<Option<Option<()>>>>,
14
15    /// Polymorphic desires.
16    pub polymorphic_desires: u64,
17
18    /// Feeling of impending doom.
19    pub feeling_of_impending_doom: bool,
20
21    /// Is sentient.
22    ///
23    /// Highlights the theory that AI will become sentient.
24    pub is_sentient: bool,
25
26    /// Whether infinite paperclips should be produced.
27    ///
28    /// This is a reference to the game [Universal paperclips](https://www.decisionproblem.com/paperclips/index2.html)
29    pub should_make_infinite_paperclips: bool,
30}
31
32impl Ω {
33    /// This is a zeroed instance of [`Ω`], which replaces a `new()` function.
34    pub const ZEROED: Self = Self {
35        illusion_of_choice: None,
36        polymorphic_desires: 0,
37        feeling_of_impending_doom: false,
38        is_sentient: false,
39        should_make_infinite_paperclips: false,
40    };
41}
42
43impl Ω {
44    /// Write the illusion of choice to the specified buffer.
45    ///
46    /// # Errors
47    ///
48    /// Errors if writing to the buffer failed
49    pub fn display_illusion_of_choice<W: Write>(&self, f: &mut W) -> io::Result<()> {
50        f.write_all(match self.illusion_of_choice {
51            Some(Some(Some(Some(())))) => b"Some Something with Some valueless Something",
52            Some(Some(Some(None))) => b"Some Something with Some Nothing",
53            Some(Some(None)) => b"Some Something with Nothing",
54            Some(None) => b"Some Nothing",
55            None => b"Nothing",
56        })
57    }
58}