fix: Corrected doctests to pass
This commit is contained in:
@@ -8,6 +8,7 @@ authors = ["EdJoPaTo <tui-tree-widget-rust-crate@edjopato.de>", "Dark-Alex-17 <a
|
||||
edition = "2021"
|
||||
keywords = ["tui", "terminal", "tree", "widget", "managarr"]
|
||||
categories = ["command-line-interface"]
|
||||
rust-version = "1.82.0"
|
||||
include = ["src/**/*", "examples/**/*", "benches/**/*", "README.md"]
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ fn init(criterion: &mut Criterion) {
|
||||
|
||||
group.bench_function("empty", |bencher| {
|
||||
bencher.iter(|| {
|
||||
let items = vec![];
|
||||
let items = Vec::<TreeItem<String, String>>::new();
|
||||
let _ = black_box(Tree::new(black_box(&items))).unwrap();
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ mod tree_state;
|
||||
/// # let mut terminal = Terminal::new(TestBackend::new(32, 32)).unwrap();
|
||||
/// let mut state = TreeState::default();
|
||||
///
|
||||
/// let item = TreeItem::new_leaf("l", "leaf");
|
||||
/// let item = TreeItem::new_leaf("l".to_owned(), "leaf".to_owned());
|
||||
/// let items = vec![item];
|
||||
///
|
||||
/// terminal.draw(|frame| {
|
||||
@@ -163,7 +163,7 @@ where
|
||||
#[test]
|
||||
#[should_panic = "duplicate identifiers"]
|
||||
fn tree_new_errors_with_duplicate_identifiers() {
|
||||
let item = TreeItem::new_leaf("same", "text");
|
||||
let item = TreeItem::new_leaf("same".to_owned(), "text".to_owned());
|
||||
let another = item.clone();
|
||||
let items = [item, another];
|
||||
let _ = Tree::new(&items).unwrap();
|
||||
|
||||
+6
-6
@@ -29,8 +29,8 @@ use ratatui::text::Text;
|
||||
///
|
||||
/// ```
|
||||
/// # use managarr_tree_widget::TreeItem;
|
||||
/// let a = TreeItem::new_leaf("l", "Leaf");
|
||||
/// let b = TreeItem::new("r", "Root", vec![a])?;
|
||||
/// let a = TreeItem::new_leaf("l".to_owned(), "Leaf".to_owned());
|
||||
/// let b = TreeItem::new("r".to_owned(), "Root".to_owned(), vec![a])?;
|
||||
/// # Ok::<(), std::io::Error>(())
|
||||
/// ```
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -174,16 +174,16 @@ impl TreeItem<&'static str, String> {
|
||||
#[test]
|
||||
#[should_panic = "duplicate identifiers"]
|
||||
fn tree_item_new_errors_with_duplicate_identifiers() {
|
||||
let item = TreeItem::new_leaf("same", "text");
|
||||
let item = TreeItem::new_leaf("same".to_owned(), "text".to_owned());
|
||||
let another = item.clone();
|
||||
TreeItem::new("root", "Root", vec![item, another]).unwrap();
|
||||
TreeItem::new("root".to_owned(), "Root".to_owned(), vec![item, another]).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic = "identifier already exists"]
|
||||
fn tree_item_add_child_errors_with_duplicate_identifiers() {
|
||||
let item = TreeItem::new_leaf("same", "text");
|
||||
let item = TreeItem::new_leaf("same".to_owned(), "text".to_owned());
|
||||
let another = item.clone();
|
||||
let mut root = TreeItem::new("root", "Root", vec![item]).unwrap();
|
||||
let mut root = TreeItem::new("root".to_owned(), "Root".to_owned(), vec![item]).unwrap();
|
||||
root.add_child(another).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user