Structopt: Support AtomicBool

Created on 23 May 2019  路  5Comments  路  Source: TeXitoi/structopt

I wanted to replace a bool in a struct opt with an AtomicBool and this didn't "just work". I suppose I have to write a custom parser for this, and pass it as a parse(...), but it would be nice if that would just work.

enhancement

Most helpful comment

There is a lot of types in libcore and libstd, and I prefer not to have magic around type name as the macro system doesn't have access to type resolving. That's why I prefer not handling AtomicBool explicitly.

All 5 comments

Looking at the docs, it is unclear to me how to do that. I basically want the same semantics as bool, e.g., if the flag is present, set it to true, and false otherwise, but it does not appear that this behavior can be achieved with custom parsers.

You're right, that's not possible now.

A new feature can be having a new parser:

|kind|signature|default|
|--|--|--|
| from_flag | fn(bool) -> T | From

@TeXitoi yes that sounds like it would allow me to solve my problem and allow others to solve problems similar to mine. Given that AtomicBool is in libcore, it might be worth adding support for it natively anyways.

There is a lot of types in libcore and libstd, and I prefer not to have magic around type name as the macro system doesn't have access to type resolving. That's why I prefer not handling AtomicBool explicitly.

I decided to take a stab at this in #271

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jackjen picture jackjen  路  7Comments

TedDriggs picture TedDriggs  路  6Comments

sharksforarms picture sharksforarms  路  6Comments

liamdawson picture liamdawson  路  5Comments

sphynx picture sphynx  路  9Comments