diff --git a/src/book.rs b/src/book.rs new file mode 100644 index 0000000..5581975 --- /dev/null +++ b/src/book.rs @@ -0,0 +1,23 @@ +#[derive(Debug)] +struct Book<'a> { + title: &'a str, + author: &'a str, + year: u128, + likes: u16, +} + +impl Book<'static> { + pub fn new_book<'a>(title: &'a str, author: &'a str, year: u128) -> Book<'a> { + Book { + title, + author, + year, + likes: 0, + } + } +} + +pub fn book_registry() { + let power = Book::new_book("power", "courtney A. kemp", 2014); + println!("latest book {:#?}", power) +} diff --git a/src/main.rs b/src/main.rs index 2d3eaad..ab85b09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ //mod strings; +mod book; mod float; mod signed; mod string; @@ -11,4 +12,5 @@ fn main() { float::intro_to_float(); string::strings(); user_struct::user_registry(); + book::book_registry(); }