Created
October 18, 2019 02:29
-
-
Save rust-play/4e61a61bfcec7f12b0461d4ae72f50fc to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
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
#[derive(Debug)] | |
struct Tokens { | |
idx: i8, | |
val: i8, | |
chr: char, | |
} | |
impl Tokens { | |
fn new(idx: i8, val: i8, chr: char) -> Tokens { | |
Tokens { | |
idx: idx, | |
val: val, | |
chr: chr, | |
} | |
} | |
fn update(&mut self, chr: char) { | |
self.chr = chr; | |
} | |
} | |
fn make_board() -> Vec<Tokens> { | |
let mut count = 0; | |
let mut spots = Vec::<Tokens>::new(); | |
let values = [4, 9, 2, 3, 5, 7, 8, 1, 6]; | |
for val in &values { | |
let tok = Tokens::new(count, *val, ' '); | |
spots.push(tok); | |
} | |
spots | |
} | |
fn main() { | |
let board = make_board(); | |
println!("{:?}", board); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment