Created
August 24, 2022 07:51
-
-
Save 0atman/f540928562284e7db2db08689b68b515 to your computer and use it in GitHub Desktop.
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 rand_derive2::RandGen; | |
use rand::random; | |
fn main() { | |
println!("Hey, world! 👻 3spoopy5me"); | |
let some_rooms: Vec<Room> = (1..=5) | |
.map(|n| Room {name: "empty room".into(), next_room: vec![], item: random()}) | |
.collect(); | |
let room = Room { | |
name: "room1".into(), | |
next_room: some_rooms, | |
item: random() | |
}; | |
dbg!(room); | |
} | |
#[derive(Debug, RandGen)] | |
struct Room{ | |
name: String, | |
next_room: Vec<Room>, | |
item: Item, | |
} | |
#[derive(Debug, RandGen)] | |
enum Item { | |
Gem, HealthPotion, Sword | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A Rust demo workshop