Page MenuHomeDevCentral

Map result values instead to use a match block

Authored by dereckson on Oct 21 2018, 21:47.



To map a result, ie a success T or an error E, into another result,
ie a success U or an error F means the code focus on T -> U, without
regard it's an Ok, and E -> F, without regard it's an Err value.

As such, it's seems more natural to express the idea with
methods manipulating tbe values than to recreate the enum container too.

The Serde library uses those map and map_err methods.

Test Plan
pub fn get_player(connection: DatabaseConnection, name: String) -> ApiJsonResponse<Player> {

Diff Detail

rLF Limiting Factor
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

dereckson requested review of this revision.Oct 21 2018, 21:47
dereckson created this revision.
dereckson accepted this revision.Oct 21 2018, 21:50
This revision is now accepted and ready to land.Oct 21 2018, 21:50
This revision was automatically updated to reflect the committed changes.