mirror of
https://git.aramjonghu.dev/AramJonghu/rustlings.git
synced 2026-09-07 02:13:29 +02:00
finished structs
This commit is contained in:
@@ -10,19 +10,18 @@ struct Fireworks {
|
|||||||
rockets: usize,
|
rockets: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Turn this function into an associated function on `Fireworks`.
|
impl Fireworks {
|
||||||
fn new_fireworks() -> Fireworks {
|
fn new() -> Self {
|
||||||
Fireworks { rockets: 0 }
|
Self { rockets: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Turn this function into a method on `Fireworks`.
|
fn add_rockets(&mut self, rockets: usize) {
|
||||||
fn add_rockets(fireworks: &mut Fireworks, rockets: usize) {
|
self.rockets += rockets
|
||||||
fireworks.rockets += rockets
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Turn this function into a method on `Fireworks`.
|
fn start(self) -> String {
|
||||||
fn start(fireworks: Fireworks) -> String {
|
"🚀".repeat(self.rockets)
|
||||||
"🚀".repeat(fireworks.rockets)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|||||||
Reference in New Issue
Block a user