Collapse the ghost-option guard into a let-chain
1 file changed,
+6 insertions,
-6 deletions
| 404 |
404 |
|
// list once the field is answered. A non-empty value no option carries is a
|
| 405 |
405 |
|
// wrong answer rather than an absent one and takes the stray-option path
|
| 406 |
406 |
|
// below.
|
| 407 |
|
- |
if value.is_empty() {
|
| 408 |
|
- |
if let Some(text) = field.placeholder {
|
| 409 |
|
- |
out.push_str("<option value=\"\" disabled selected>");
|
| 410 |
|
- |
escape_into(text, out);
|
| 411 |
|
- |
out.push_str("</option>");
|
| 412 |
|
- |
}
|
|
407 |
+ |
if value.is_empty()
|
|
408 |
+ |
&& let Some(text) = field.placeholder
|
|
409 |
+ |
{
|
|
410 |
+ |
out.push_str("<option value=\"\" disabled selected>");
|
|
411 |
+ |
escape_into(text, out);
|
|
412 |
+ |
out.push_str("</option>");
|
| 413 |
413 |
|
}
|
| 414 |
414 |
|
if !value.is_empty() && !options.iter().any(|opt| opt.value == value) {
|
| 415 |
415 |
|
// The one place an escaped value is worth keeping: it is written twice,
|