MCPcopy Create free account
hub / github.com/ahgamut/rust-ape-example / process

Function process

src/bin/error_option_unwrap_map.rs:37–41  ·  view source on GitHub ↗

A function to peel, chop, and cook food all in sequence. We chain multiple uses of `map()` to simplify the code.

(food: Option<Food>)

Source from the content-addressed store, hash-verified

35// A function to peel, chop, and cook food all in sequence.
36// We chain multiple uses of `map()` to simplify the code.
37fn process(food: Option<Food>) -> Option<Cooked> {
38 food.map(|f| Peeled(f))
39 .map(|Peeled(f)| Chopped(f))
40 .map(|Chopped(f)| Cooked(f))
41}
42
43// Check whether there's food or not before trying to eat it!
44fn eat(food: Option<Cooked>) {

Callers 1

part0Function · 0.85

Calls 3

PeeledClass · 0.85
ChoppedClass · 0.85
CookedClass · 0.85

Tested by

no test coverage detected