Good vs. Evil

duckfan77

Popular Member
Mar 18, 2013
80
575
118
21 Think I did well on the midterm! Didn't get to the bonus problem, but the rest I feel good on.
 

lenscas

Over-Achiever
Jul 31, 2013
2,031
1,808
248
21 I managed to work on Arena_keeper a bit more.

Module system is now almost done. I only need to make sure that mods don't trample over each other and add 1 thing back in and its done. After that, I simply need to clean up the code and update the README and it can be merged.

Working on this also caused me to discover something new about rust's syntax, to do with enums and pattern matching.
Code:
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
enum Tile {
  BaseTile {
  image: String,
  end: f64,
  baseSpeed: f64,
  },
  ExtendingTile {
  end: f64,
  image: String,
  extend: TileType,
  baseSpeed: Option<f64>,
  },
}
impl Tile {
  pub fn get_end(&self) -> f64 {
  match &self {
  Tile::BaseTile { end, .. } | Tile::ExtendingTile { end, .. } => *end,
  }
  }
}
I already knew that entries in an enum could hold values. However, I always used that like this:
Code:
pub enum Example {
    NoValue,
    OneValue(f64),
    TwoValues(f64,i32)
}
But, today I learned that you can also basically use them like structs and that you can be selective about which fields you want out of them when pattern matching. This means that I only need one branch for every field that the two tile types share (like image, or end) in the above example.
 

lenscas

Over-Achiever
Jul 31, 2013
2,031
1,808
248
21 my desktop decided to not recognize its audio jacks any more.

Luckily, my monitor is connected using HDMI and has a line out.

So... now sound uses this path

Desktop -> Monitor -> Server -> Amplifier -> Speaker
 

lenscas

Over-Achiever
Jul 31, 2013
2,031
1,808
248
19 decided to push what I have for the module system to master.

It should be on feature parity with the old generated code, however mods aren't name spaced and are thus able to trample over each other.

The reason I decided to push is simple, a new GUI library appeared that seems actually rather nice, works on WASM AND it is render agnostic. Meaning that I rather look into that

The library: https://github.com/hecrj/iced

With that I may even be able to bring back the floating window style of the yew based version, if people like that.