Page MenuHomeDevCentral

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

Authored by dereckson on Tue, Oct 28, 21:16.

Details

Summary

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

Test Plan

New unit tests for new methods

Diff Detail

Repository
rKERUALD Keruald libraries development repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable