refactor: improve lifetime names

This commit is contained in:
EdJoPaTo
2024-05-13 00:33:34 +02:00
parent 04ecf5388f
commit 9dcccba31d
4 changed files with 16 additions and 16 deletions
+6 -6
View File
@@ -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
View File
@@ -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
View File
@@ -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()