const DATA: &'static str = " [D] [N] [C] [Z] [M] [P] 1 2 3 move 1 from 2 to 1 move 3 from 1 to 3 move 2 from 2 to 1 move 1 from 1 to 2 "; struct State { stacks: Vec>, } impl std::str::FromStr for State { fn from_str(data: &str) -> State { let lines: Vec<&str> = data.lines().collect(); let mut stacks = Vec::new(Vec::new()); // skip the first row, because it's just the stack numbers for row in lines.rev().skip(1) { for (i, ident) in row.split(' ') { let ident = ident.trim_matches(|c| c == '[' || c == ']'); } } } }