fix: must_use the structs

This commit is contained in:
EdJoPaTo
2024-05-23 12:03:02 +02:00
parent 136599257a
commit d676f66504
6 changed files with 11 additions and 12 deletions
+3 -9
View File
@@ -50,6 +50,7 @@ mod tree_state;
/// })?;
/// # Ok::<(), std::io::Error>(())
/// ```
#[must_use]
#[derive(Debug, Clone)]
pub struct Tree<'a, Identifier> {
items: &'a [TreeItem<'a, Identifier>],
@@ -107,7 +108,6 @@ where
}
#[allow(clippy::missing_const_for_fn)]
#[must_use]
pub fn block(mut self, block: Block<'a>) -> Self {
self.block = Some(block);
self
@@ -118,43 +118,36 @@ where
/// Experimental: Can change on any release without any additional notice.
/// Its there to test and experiment with whats possible with scrolling widgets.
/// Also see <https://github.com/ratatui-org/ratatui/issues/174>
#[must_use]
pub const fn experimental_scrollbar(mut self, scrollbar: Option<Scrollbar<'a>>) -> Self {
self.scrollbar = scrollbar;
self
}
#[must_use]
pub const fn style(mut self, style: Style) -> Self {
self.style = style;
self
}
#[must_use]
pub const fn highlight_style(mut self, style: Style) -> Self {
self.highlight_style = style;
self
}
#[must_use]
pub const fn highlight_symbol(mut self, highlight_symbol: &'a str) -> Self {
self.highlight_symbol = highlight_symbol;
self
}
#[must_use]
pub const fn node_closed_symbol(mut self, symbol: &'a str) -> Self {
self.node_closed_symbol = symbol;
self
}
#[must_use]
pub const fn node_open_symbol(mut self, symbol: &'a str) -> Self {
self.node_open_symbol = symbol;
self
}
#[must_use]
pub const fn node_no_children_symbol(mut self, symbol: &'a str) -> Self {
self.node_no_children_symbol = symbol;
self
@@ -166,7 +159,8 @@ where
fn tree_new_errors_with_duplicate_identifiers() {
let item = TreeItem::new_leaf("same", "text");
let another = item.clone();
Tree::new(&[item, another]).unwrap();
let items = [item, another];
let _: Tree<_> = Tree::new(&items).unwrap();
}
impl<Identifier> StatefulWidget for Tree<'_, Identifier>