Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve house building example with more comments #296

Merged
merged 1 commit into from
Feb 21, 2021
Merged
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
10 changes: 8 additions & 2 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ pub enum WrapAlgorithm {
/// name: &'a str,
/// hours: usize, // Time needed to complete task.
/// sweep: usize, // Time needed for a quick sweep after task during the day.
/// cleanup: usize, // Time needed to cleanup after task at end of day.
/// cleanup: usize, // Time needed for full cleanup if day ends with this task.
/// }
///
/// impl Fragment for Task<'_> {
Expand All @@ -584,9 +584,15 @@ pub enum WrapAlgorithm {
/// Task { name: "Bathrooms", hours: 2, sweep: 1, cleanup: 2 },
/// ];
///
/// // Fill tasks into days, taking `day_length` into account. The
/// // output shows the hours worked per day along with the names of
/// // the tasks for that day.
/// fn assign_days<'a>(tasks: &[Task<'a>], day_length: usize) -> Vec<(usize, Vec<&'a str>)> {
/// let mut days = Vec::new();
/// for day in wrap_first_fit(&tasks, |i| day_length) {
/// // Assign tasks to days. The assignment is a vector of slices,
/// // with a slice per day.
/// let assigned_days: Vec<&[Task<'a>]> = wrap_first_fit(&tasks, |i| day_length);
/// for day in assigned_days.iter() {
/// let last = day.last().unwrap();
/// let work_hours: usize = day.iter().map(|t| t.hours + t.sweep).sum();
/// let names = day.iter().map(|t| t.name).collect::<Vec<_>>();
Expand Down