Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/book.rs
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//mod strings;
mod book;
mod float;
mod signed;
mod string;
Expand All @@ -11,4 +12,5 @@ fn main() {
float::intro_to_float();
string::strings();
user_struct::user_registry();
book::book_registry();
}