Adding initial code for data storage
This commit is contained in:
15
src/checklist.rs
Normal file
15
src/checklist.rs
Normal file
@@ -0,0 +1,15 @@
|
||||
struct list_item {
|
||||
todo:String,
|
||||
done:bool,
|
||||
subtodo:Vec:list_item
|
||||
}
|
||||
|
||||
struct checklist {
|
||||
name:String,
|
||||
todo_list:Vec:list_item
|
||||
}
|
||||
|
||||
fn init_checklists() -> Vec<checklist> {
|
||||
let all_checklists:Vec<checklist> = {};
|
||||
return all_checklists;
|
||||
}
|
||||
53
src/main.rs
53
src/main.rs
@@ -1,3 +1,52 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
|
||||
fn test_by_ref(my_num:&mut u8) {
|
||||
*my_num = 26;
|
||||
}
|
||||
|
||||
fn test_hello(my_num:u16) -> u16 {
|
||||
println!("Your num {}", my_num);
|
||||
return 522;
|
||||
}
|
||||
|
||||
fn display(my_string:&mut String) {
|
||||
println!("My string {}", *my_string);
|
||||
}
|
||||
|
||||
fn display_vec(my_vec:Vec<i32>) -> Vec<i32> {
|
||||
println!("inside display vec: {:?}", my_vec);
|
||||
return my_vec;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let company:&'static str = "Whoot mate";
|
||||
let empty_string = String::new();
|
||||
let content_string = String::from("my string whee");
|
||||
|
||||
let mut test_int:u8 = 8;
|
||||
|
||||
test_int += 5;
|
||||
println!("Hello, world! {}", test_int);
|
||||
println!("Hollo {} welcome", company);
|
||||
println!("length of empty is {}", empty_string.len());
|
||||
println!("length of from is {}", content_string.len());
|
||||
println!("length of static is {}", company.len());
|
||||
|
||||
|
||||
if test_int > 5 {
|
||||
println!("Is greater");
|
||||
}
|
||||
|
||||
println!("Running away now : {}", test_hello(test_int.into()));
|
||||
test_by_ref(&mut test_int);
|
||||
println!("test int = {}", test_int);
|
||||
|
||||
let mut test_str:String = String::from("Whats up doc");
|
||||
display(&mut test_str);
|
||||
println!("outside {}", test_str);
|
||||
|
||||
let mut my_vec = vec![1,2,4];
|
||||
my_vec = display_vec(my_vec);
|
||||
println!("{:?}", my_vec);
|
||||
|
||||
let _mylist:Vec<checklist> = init_checklists();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user