mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-04-05 18:15:49 +02:00
I've taken some work by @fw-immunant and others on the new organization of the course and condensed it into a form amenable to a text editor and some computational analysis. You can see the inputs in `course.py` but the interesting bits are the output: `outline.md` and `slides.md`. The idea is to break the course into more, smaller segments with exercises at the ends and breaks in between. So `outline.md` lists the segments, their duration, and sums those durations up per-day. It shows we're about an hour too long right now! There are more details of the segments in `slides.md`, or you can see mostly the same stuff in `course.py`. This now contains all of the content from the v1 course, ensuring both that we've covered everything and that we'll have somewhere to redirect every page. Fixes #1082. Fixes #1465. --------- Co-authored-by: Nicole LeGare <dlegare.1001@gmail.com> Co-authored-by: Martin Geisler <mgeisler@google.com>
43 lines
776 B
Markdown
43 lines
776 B
Markdown
---
|
|
minutes: 20
|
|
---
|
|
|
|
# Exercise: Builder Type
|
|
|
|
In this example, we will implement a complex data type that owns all of its
|
|
data. We will use the "builder pattern" to support building a new value
|
|
piece-by-piece, using convenience functions.
|
|
|
|
Fill in the missing pieces.
|
|
|
|
```rust,should_panic,editable
|
|
{{#include exercise.rs:Package}}
|
|
{{#include exercise.rs:as_dependency}}
|
|
todo!("1")
|
|
}
|
|
}
|
|
|
|
{{#include exercise.rs:PackageBuilder}}
|
|
{{#include exercise.rs:new}}
|
|
todo!("2")
|
|
}
|
|
|
|
{{#include exercise.rs:version}}
|
|
|
|
{{#include exercise.rs:authors}}
|
|
todo!("3")
|
|
}
|
|
|
|
{{#include exercise.rs:dependency}}
|
|
todo!("4")
|
|
}
|
|
|
|
{{#include exercise.rs:language}}
|
|
todo!("5")
|
|
}
|
|
|
|
{{#include exercise.rs:build}}
|
|
|
|
{{#include exercise.rs:main}}
|
|
```
|