Skip to content

Commit

Permalink
Merge pull request #296 from mgeisler/improve-house-example
Browse files Browse the repository at this point in the history
Improve house building example with more comments
  • Loading branch information
mgeisler authored Feb 21, 2021
2 parents 1007c95 + d75bc6d commit 9ad04ee
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit 9ad04ee

Please sign in to comment.