cargo install cargo-edit
cargo upgrade --ignore-rust-version --incompatible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// [dependencies] | |
// uuid = { version = "1.6.1", features = ["v4"] } | |
use std::collections::{HashMap, VecDeque}; | |
#[derive(Clone, Debug)] | |
pub enum Message { | |
String(String), | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "chitauri" | |
version = "0.1.0" | |
edition = "2021" | |
[dependencies] | |
sdl2 = { version = "0.36.0", features = ["bundled"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use petgraph::graph::{DiGraph, NodeIndex}; | |
use petgraph::Direction; | |
use nalgebra::{Vector3, Isometry3}; | |
use std::collections::HashMap; | |
#[derive(Debug, Clone)] | |
enum SceneNode { | |
Spatial(SpatialNode), | |
Mesh { base: SpatialNode, vertices: Vec<Vector3<f32>> }, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Emulator { | |
register: [u8; 2], // Two general-purpose registers | |
program_counter: usize, | |
memory: [u8; 256], // Simplified memory | |
} | |
enum Instruction { | |
Load(u8, u8), // Load a value into a register | |
Add, // Add two registers | |
Subtract, // Subtract two registers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::convert::TryFrom; | |
use std::num::ParseIntError; | |
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)] | |
struct SemanticVersion { | |
major: u32, | |
minor: u32, | |
patch: u32, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use petgraph::graphmap::DiGraphMap; | |
use serde::{Deserialize, Serialize}; | |
use std::{collections::HashMap, error::Error, fmt, hash::Hash}; | |
#[derive(Debug)] | |
pub struct NodeGraphError { | |
details: String, | |
} | |
impl NodeGraphError { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn contains_single_num_in_range(s: &str, section_index: usize, min: u8, max: u8) -> Option<u8> { | |
s.split('/') | |
.nth(section_index)? | |
.split('-') | |
.filter_map(|part| part.parse::<u8>().ok()) | |
.find(|&num| (min..=max).contains(&num)) | |
} | |
#[cfg(test)] | |
mod tests { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use petgraph::{graph::NodeIndex, prelude::*}; | |
use std::ops::{Index, IndexMut}; | |
pub trait Aggregatable: Clone + PartialEq + std::fmt::Debug { | |
fn aggregate(&self, parent: &Self) -> Self; | |
} | |
// The SceneGraph is now generic over the type of the transform | |
#[derive(Default)] | |
pub struct SceneGraph<T: Aggregatable>(pub Graph<T, ()>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// =========================== | |
// Approach 1: Direct Function | |
// =========================== | |
struct DirectProcessor { | |
process: fn() -> &'static str, | |
} | |
impl DirectProcessor { | |
fn process_data() -> &'static str { |