mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
string2Int(): Return std::optional
This commit is contained in:
parent
29a445840a
commit
6548b89cc4
17 changed files with 82 additions and 69 deletions
|
@ -219,10 +219,10 @@ LegacyArgs::LegacyArgs(const std::string & programName,
|
|||
.description = description,
|
||||
.labels = {"n"},
|
||||
.handler = {[=](std::string s) {
|
||||
unsigned int n;
|
||||
if (!string2Int(s, n))
|
||||
if (auto n = string2Int<unsigned int>(s))
|
||||
settings.set(dest, std::to_string(*n));
|
||||
else
|
||||
throw UsageError("'%s' is not an integer", s);
|
||||
settings.set(dest, std::to_string(n));
|
||||
}}
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue