diff --git a/Book b/Book new file mode 100644 index 0000000..e69de29 diff --git a/src/constructor.rs b/src/constructor.rs new file mode 100644 index 0000000..7f862b4 --- /dev/null +++ b/src/constructor.rs @@ -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); +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 2d3eaad..989be4a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(); }