refactor: improve lifetime names
This commit is contained in:
+3
-3
@@ -9,12 +9,12 @@ use ratatui::widgets::{Block, Scrollbar, ScrollbarOrientation};
|
||||
use ratatui::{Frame, Terminal};
|
||||
use tui_tree_widget::{Tree, TreeItem, TreeState};
|
||||
|
||||
struct App<'a> {
|
||||
struct App {
|
||||
state: TreeState<&'static str>,
|
||||
items: Vec<TreeItem<'a, &'static str>>,
|
||||
items: Vec<TreeItem<'static, &'static str>>,
|
||||
}
|
||||
|
||||
impl<'a> App<'a> {
|
||||
impl App {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
state: TreeState::default(),
|
||||
|
||||
+6
-6
@@ -5,12 +5,12 @@ use crate::tree_item::TreeItem;
|
||||
/// A flattened item of all visible [`TreeItem`]s.
|
||||
///
|
||||
/// Generated via [`TreeState::flatten`](crate::TreeState::flatten).
|
||||
pub struct Flattened<'a, Identifier> {
|
||||
pub struct Flattened<'text, Identifier> {
|
||||
pub identifier: Vec<Identifier>,
|
||||
pub item: &'a TreeItem<'a, Identifier>,
|
||||
pub item: &'text TreeItem<'text, Identifier>,
|
||||
}
|
||||
|
||||
impl<'a, Identifier> Flattened<'a, Identifier> {
|
||||
impl<Identifier> Flattened<'_, Identifier> {
|
||||
/// Zero based depth. Depth 0 means 0 indentation.
|
||||
#[must_use]
|
||||
pub fn depth(&self) -> usize {
|
||||
@@ -22,11 +22,11 @@ impl<'a, Identifier> Flattened<'a, Identifier> {
|
||||
///
|
||||
/// `current` starts empty: `&[]`
|
||||
#[must_use]
|
||||
pub fn flatten<'a, Identifier>(
|
||||
pub fn flatten<'text, Identifier>(
|
||||
opened: &HashSet<Vec<Identifier>>,
|
||||
items: &'a [TreeItem<'a, Identifier>],
|
||||
items: &'text [TreeItem<'text, Identifier>],
|
||||
current: &[Identifier],
|
||||
) -> Vec<Flattened<'a, Identifier>>
|
||||
) -> Vec<Flattened<'text, Identifier>>
|
||||
where
|
||||
Identifier: Clone + PartialEq + Eq + core::hash::Hash,
|
||||
{
|
||||
|
||||
+2
-2
@@ -169,7 +169,7 @@ fn tree_new_errors_with_duplicate_identifiers() {
|
||||
Tree::new(vec![item, another]).unwrap();
|
||||
}
|
||||
|
||||
impl<'a, Identifier> StatefulWidget for Tree<'a, Identifier>
|
||||
impl<Identifier> StatefulWidget for Tree<'_, Identifier>
|
||||
where
|
||||
Identifier: Clone + PartialEq + Eq + core::hash::Hash,
|
||||
{
|
||||
@@ -332,7 +332,7 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, Identifier> Widget for Tree<'a, Identifier>
|
||||
impl<Identifier> Widget for Tree<'_, Identifier>
|
||||
where
|
||||
Identifier: Clone + Default + Eq + core::hash::Hash,
|
||||
{
|
||||
|
||||
+5
-5
@@ -34,13 +34,13 @@ use ratatui::text::Text;
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TreeItem<'a, Identifier> {
|
||||
pub struct TreeItem<'text, Identifier> {
|
||||
pub(super) identifier: Identifier,
|
||||
pub(super) text: Text<'a>,
|
||||
pub(super) text: Text<'text>,
|
||||
pub(super) children: Vec<Self>,
|
||||
}
|
||||
|
||||
impl<'a, Identifier> TreeItem<'a, Identifier>
|
||||
impl<'text, Identifier> TreeItem<'text, Identifier>
|
||||
where
|
||||
Identifier: Clone + PartialEq + Eq + core::hash::Hash,
|
||||
{
|
||||
@@ -48,7 +48,7 @@ where
|
||||
#[must_use]
|
||||
pub fn new_leaf<T>(identifier: Identifier, text: T) -> Self
|
||||
where
|
||||
T: Into<Text<'a>>,
|
||||
T: Into<Text<'text>>,
|
||||
{
|
||||
Self {
|
||||
identifier,
|
||||
@@ -64,7 +64,7 @@ where
|
||||
/// Errors when there are duplicate identifiers in the children.
|
||||
pub fn new<T>(identifier: Identifier, text: T, children: Vec<Self>) -> std::io::Result<Self>
|
||||
where
|
||||
T: Into<Text<'a>>,
|
||||
T: Into<Text<'text>>,
|
||||
{
|
||||
let identifiers = children
|
||||
.iter()
|
||||
|
||||
Reference in New Issue
Block a user