meh / rust-terminfo

Terminal information for Rust.
Other
40 stars 15 forks source link

Can `Value::Boolean(false)` exist in the database? #2

Closed Stebalien closed 7 years ago

Stebalien commented 7 years ago

Unless I'm mistaken, it can't. Any reason to not just change this to Value::Flag or Value::True?

meh commented 7 years ago

Currently boolean flags when accessed through the typesafe getter always return a value, even if they're not defined in the database.

So Value::Boolean(false) cannot be present in the database, but it's used by the API.

Personally I prefer it this way, what do you think?

Stebalien commented 7 years ago

If we're talking about the same thing, the typesafe getter doesn't return Value::Boolean, it returns CapabilityType(true|false). It's not really an issue, I just prefer not to have unused variants :).

meh commented 7 years ago

@Stebalien ah wait, you're right, it's an artifact from the first iteration of the type-safe API.

On the other hand there can be false boolean flags, but they're kind of an implementation detail since they're just used for offsets within the name table.

So it's either removing the value within the variant, or adding the false booleans.

Although the latter ends up being more verbose to check if a boolean capability is on, since you'd have to check for None and Some(Value::Boolean(false)).

I guess I'll go with the former.

meh commented 7 years ago

There's now Value::True instead of Value::Boolean(bool).