HomeDevCentral

Implement getValueOr, getValueOrElse, or, orElse for Result and Option

Description

Implement getValueOr, getValueOrElse, or, orElse for Result and Option

Summary:
For both Result and Option types:

  • getValueOr, GetValueOrElse returns the value or a default value
  • or, orElse allows to chain operations

To pick between the -or or -orElse variant:

  • -or is for eager evaluation or provide a scalar
  • -orElse is for lazy evaluation of a callable

The new methods follow the same patterns than or, or_else,
unwrap_or and unwrap_or_else in Rust standard library.

Ref T2173

Test Plan:

  • unit tests
  • User::resolveUserID in Obsidian Workspaces (D3846)

Differential Revision: https://devcentral.nasqueron.org/D3847

Details