HomeDevCentral

Add support for Option::from() and Environment::tryGet()

Description

Add support for Option::from() and Environment::tryGet()

Option::from simplifies the construction of Option types.
It allows nullable values (?T) to be converted into Option<T>:

  • None when the value is null
  • Some(value) otherwise

Example: Option::from(44) returns Some(44)

Environment::tryGet() is introduced to return an Option instead of throwing
an exception when querying an environment variable.

Environment::tryGet() returns an Option type instead of throwing an exception
when querying an environment variable. The existing Environment::get() method
remains unchanged and still throws an exception on failure.

Ref T2164

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

Details

Provenance
derecksonAuthored on Tue, Oct 28, 21:06
derecksonPushed on Tue, Oct 28, 21:18
Differential Revision
D3818: Add support for Option::from() and Environment::tryGet()
Parents
rKOT826acb70aabf: Import _ERROR constants into global debug space
Branches
Unknown
Tags
Unknown
References
HEAD -> main, tag: 0.16.0
Tasks
T2164: Parse YAML configuration