Skip to content

implement: src/closures -- stat aggregation, higher-order functions #3

@BryanChasko

Description

@BryanChasko

topic: closures

closures in rust capture their environment by value or by reference.
different from python lambdas -- rust closures have explicit capture rules.

concepts to demonstrate

  • closure syntax: |args| body
  • capturing by reference vs by value (move keyword)
  • Fn, FnMut, FnOnce trait bounds
  • closures as function arguments (higher-order functions)
  • returning closures from functions

patriots theme

aggregate patriots season stats using closures passed to fold and map.
build a stat_filter closure factory for different position groups.

file

src/closures/stat_aggregator.rs

reference

python mirror: libraries_2_statistics_2023_patriots_qb_shuffle.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions