• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

veeso / tui-realm-stdlib / 15137208932

20 May 2025 12:13PM UTC coverage: 67.595% (-0.7%) from 68.289%
15137208932

push

github

web-flow
Fix clippy lints, apply some pedantic fixes and general small improvements (#32)

* style(examples): directly have values as a type instead of casting

* style(examples/utils): ignore unused warnings

* style: run clippy auto fix

and remove redundant tests from "label"

* style: apply some clippy pedantic auto fixes

* test: set specific strings for "should_panic"

So that other panics are catched as failed tests.

* style(bar_chart): remove casting to "u64" when "usize" is directly provided and needed

* refactor(table): move making rows to own function

To appease "clippy::too_many_lines" and slightly reduce nesting.

* style: add "#[must_use]" where applicable

To hint not to forget a value.

104 of 192 new or added lines in 19 files covered. (54.17%)

12 existing lines in 2 files now uncovered.

2985 of 4416 relevant lines covered (67.6%)

1.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.18
/src/components/phantom.rs
1
//! ## Phantom
2
//!
3
//! `Phantom` is a component which is not rendered. It only purpose is to become a global listener in a tui-realm application
4
//! for some kind of events using subscriptions.
5
//!
6
//! An example would be a listener for `<ESC>` key to terminate the application.
7
//! The Phantom allows you not to write a listener for each component for the `ESC` key, but just to subscribe the phantom to it.
8

9
use tuirealm::command::{Cmd, CmdResult};
10
use tuirealm::props::{AttrValue, Attribute, Props};
11
use tuirealm::ratatui::layout::Rect;
12
use tuirealm::{Frame, MockComponent, State};
13

14
// -- Component
15

16
/// ## Phantom
17
///
18
/// a component which is not rendered. It only purpose is to become a global listener in a tui-realm application
19
/// for some kind of events using subscriptions.
20
#[derive(Default)]
21
pub struct Phantom {
22
    props: Props,
23
}
24

25
impl MockComponent for Phantom {
26
    fn view(&mut self, _render: &mut Frame, _area: Rect) {}
×
27

28
    fn query(&self, attr: Attribute) -> Option<AttrValue> {
×
29
        self.props.get(attr)
×
30
    }
×
31

32
    fn attr(&mut self, attr: Attribute, value: AttrValue) {
×
NEW
33
        self.props.set(attr, value);
×
34
    }
×
35

36
    fn state(&self) -> State {
1✔
37
        State::None
1✔
38
    }
1✔
39

40
    fn perform(&mut self, _cmd: Cmd) -> CmdResult {
×
41
        CmdResult::None
×
42
    }
×
43
}
44

45
#[cfg(test)]
46
mod tests {
47

48
    use super::*;
49

50
    use pretty_assertions::assert_eq;
51

52
    #[test]
53
    fn test_components_phantom() {
1✔
54
        let component = Phantom::default();
1✔
55
        // Get value
56
        assert_eq!(component.state(), State::None);
1✔
57
    }
1✔
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc