gyscos / gyscos/cursive

[BUG] Calling find_name() in the wrong order makes things unfindable

Open
#752 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
4.8k
Forks
270
Avg merge
5d 19h
Merged PRs (30d)
2

Description

**Describe the bug**
The repro below panics with "tv" being `None` when unwrapped. If the two `find_name()` calls are swapped there is no problem.

I don't think this is mentioned as a something to be avoided anywhere. I am still fairly new to Rust so my apologies if there is something idiomatic I'm missing here.

**To Reproduce**
```
use cursive::{
view::Nameable,
views::{Dialog, TextView},
};

fn main() {
let mut siv = cursive::default();

siv.add_layer(Dialog::around(TextView::new("tv").with_name("tv")).with_name("d"));

let _a = siv.find_name::("d").unwrap();
let _b = siv.find_name::("tv").unwrap();
}
```

**Expected behavior**
Order of calls to `find_name()` makes no difference. If the problem was just I should drop the result of `find_name()` before making another call, that would be fine with me provided it were documented/enforced.

**Environment**
* Operating system used: macOS 13.5.1
* Backend used: ncurses
* Current locale: en_US.UTF-8
* Cursive version: 75bc082350e7d5c3d006040d3392f524d5170f55

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.