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
Empty file added Book
Empty file.
31 changes: 31 additions & 0 deletions src/constructor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#[derive(Debug)]
pub struct Book<'a> {
pub title: &'a str,
pub author: &'a str,
pub year: i32,
pub likes: i32,


}

impl<'a> Book<'a> {
pub fn new(title: &'a str, author: &'a str, year: i32) -> Book<'a> {
Book {
title,
author,
year,
likes: 0
}

}

}

pub fn constructors () {
let new_book = Book::new (
"The Hidden Ember Ignited the Sky",
"Jemiiah",
2027,
);
println!("the new_book overview is {:?}", new_book);
}
26 changes: 14 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
//mod strings;
mod float;
mod signed;
mod string;
mod unsigned;
mod user_struct;
// //mod strings;
// mod float;
// mod signed;
// mod string;
// mod unsigned;
// mod user_struct;
mod constructor;

fn main() {
unsigned::intro_to_u();
signed::intro_to_i();
float::intro_to_float();
string::strings();
user_struct::user_registry();
fn main() {
// unsigned::intro_to_u();
// signed::intro_to_i();
// float::intro_to_float();
// string::strings();
// user_struct::user_registry();
constructor::constructors();
}