QoL code and made manager mutable
This commit is contained in:
parent
8cf5ea3ec8
commit
4dde4f1596
2 changed files with 18 additions and 17 deletions
|
@ -3,17 +3,17 @@ use crate::{board, manager};
|
|||
use std::{io, process::exit};
|
||||
|
||||
// Structures
|
||||
pub struct Interface {
|
||||
manager: manager::Manager,
|
||||
|
||||
running: bool,
|
||||
pub struct Interface<'a> {
|
||||
manager: &'a mut manager::Manager,
|
||||
|
||||
pub running: bool,
|
||||
page: u32,
|
||||
on: u32
|
||||
}
|
||||
|
||||
// Implementations
|
||||
impl Interface {
|
||||
pub fn init(manager: manager::Manager) -> Interface{
|
||||
impl<'a> Interface<'a> {
|
||||
pub fn init(manager: &'a mut manager::Manager) -> Interface<'a>{
|
||||
// Return result
|
||||
return Interface {manager: manager, running: true, page: 0, on: 0};
|
||||
}
|
||||
|
@ -98,15 +98,12 @@ impl Interface {
|
|||
}
|
||||
|
||||
pub fn run(&mut self) {
|
||||
while self.running {
|
||||
|
||||
match self.page {
|
||||
0 => self.p_0(),
|
||||
1 => self.p_1(),
|
||||
2 => self.p_2(),
|
||||
_ => Interface::error("Invalid Page")
|
||||
}
|
||||
|
||||
// Based on the page do something
|
||||
match self.page {
|
||||
0 => self.p_0(),
|
||||
1 => self.p_1(),
|
||||
2 => self.p_2(),
|
||||
_ => Interface::error("Invalid Page")
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,6 +14,10 @@ fn main() {
|
|||
managed.parse(String::from("data/user.json"));
|
||||
|
||||
// Passing this through to the interface
|
||||
let mut int: interface::Interface = interface::Interface::init(managed);
|
||||
int.run();
|
||||
let mut int: interface::Interface = interface::Interface::init(&mut managed);
|
||||
|
||||
// Running the interface
|
||||
while int.running {
|
||||
int.run();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue