Switch todo!() to unreachable!/unimplemented! where it matters

This commit is contained in:
Jonathan Kelley committed 2024-01-31 16:26:20 -08:00
1 parent a14789eebc
commit 8f07d881a6
27 files changed
+73 -180

No files matched your search

+1 -1
View File
@@ -17,7 +17,7 @@ loop {
}
# fn app() -> Element { None }
# struct SomeRenderer; impl SomeRenderer { fn new() -> SomeRenderer { SomeRenderer; } async fn event() -> () { todo!() } }
# struct SomeRenderer; impl SomeRenderer { fn new() -> SomeRenderer { SomeRenderer; } async fn event() -> () { unimplemented!() } }
```
## Features
+2 -2
View File
@@ -150,8 +150,8 @@ impl<T: std::fmt::Debug> std::fmt::Debug for Event<T> {
/// }
///
/// #[derive(Props)]
/// struct MyProps<'a> {
/// onclick: EventHandler<'a, MouseEvent>,
/// struct MyProps {
/// onclick: EventHandler<MouseEvent>,
/// }
///
/// fn MyComponent(cx: MyProps) -> Element {
+1 -1
View File
@@ -72,7 +72,7 @@ where
{
type Builder = P;
fn builder() -> Self::Builder {
todo!()
unreachable!("Root props technically are never built")
}
fn memoize(&mut self, _other: &Self) -> bool {
true
-97
View File
@@ -77,100 +77,3 @@ fn events_generate() {
]
)
}
// #[test]
// fn components_generate() {
// fn app() -> Element {
// let render_phase = use_hook(|| 0);
// *render_phase += 1;
// match *render_phase {
// 1 => rsx_without_templates!("Text0"),
// 2 => rsx_without_templates!(div {}),
// 3 => rsx_without_templates!("Text2"),
// 4 => rsx_without_templates!(Child {}),
// 5 => rsx_without_templates!({ None as Option<()> }),
// 6 => rsx_without_templates!("text 3"),
// 7 => rsx_without_templates!({ (0..2).map(|f| rsx_without_templates!("text {f}")) }),
// 8 => rsx_without_templates!(Child {}),
// _ => todo!(),
// })
// };
// fn Child() -> Element {
// println!("Running child");
// render_without_templates! {
// h1 {}
// })
// }
// let mut dom = VirtualDom::new(app);
// let edits = dom.rebuild_to_vec();
// assert_eq!(
// edits.edits,
// [
// CreateTextNode { root: Some(1), text: "Text0" },
// AppendChildren { root: Some(0), children: vec![1] }
// ]
// );
// assert_eq!(
// dom.hard_diff(ScopeId::ROOT).edits,
// [
// CreateElement { root: Some(2), tag: "div", children: 0 },
// ReplaceWith { root: Some(1), nodes: vec![2] }
// ]
// );
// assert_eq!(
// dom.hard_diff(ScopeId::ROOT).edits,
// [
// CreateTextNode { root: Some(1), text: "Text2" },
// ReplaceWith { root: Some(2), nodes: vec![1] }
// ]
// );
// // child {}
// assert_eq!(
// dom.hard_diff(ScopeId::ROOT).edits,
// [
// CreateElement { root: Some(2), tag: "h1", children: 0 },
// ReplaceWith { root: Some(1), nodes: vec![2] }
// ]
// );
// // placeholder
// assert_eq!(
// dom.hard_diff(ScopeId::ROOT).edits,
// [
// CreatePlaceholder { root: Some(1) },
// ReplaceWith { root: Some(2), nodes: vec![1] }
// ]
// );
// assert_eq!(
// dom.hard_diff(ScopeId::ROOT).edits,
// [
// CreateTextNode { root: Some(2), text: "text 3" },
// ReplaceWith { root: Some(1), nodes: vec![2] }
// ]
// );
// assert_eq!(
// dom.hard_diff(ScopeId::ROOT).edits,
// [
// CreateTextNode { text: "text 0", root: Some(1) },
// CreateTextNode { text: "text 1", root: Some(3) },
// ReplaceWith { root: Some(2), nodes: vec![1, 3] },
// ]
// );
// assert_eq!(
// dom.hard_diff(ScopeId::ROOT).edits,
// [
// CreateElement { tag: "h1", root: Some(2), children: 0 },
// ReplaceWith { root: Some(1), nodes: vec![2] },
// Remove { root: Some(3) },
// ]
// );
// }
+1 -1
View File
@@ -95,7 +95,7 @@ fn diffing_drops_old() {
match generation() % 2 {
0 => rsx!( ChildComp1 { name: "asdasd".to_string() }),
1 => rsx!( ChildComp2 { name: "asdasd".to_string() }),
_ => todo!()
_ => unreachable!()
}
}
}
-8
View File
@@ -97,14 +97,6 @@ fn memo_works_properly() {
let mut dom = VirtualDom::new(app);
dom.rebuild(&mut dioxus_core::NoOpMutations);
// todo!()
// dom.hard_diff(ScopeId::ROOT);
// dom.hard_diff(ScopeId::ROOT);
// dom.hard_diff(ScopeId::ROOT);
// dom.hard_diff(ScopeId::ROOT);
// dom.hard_diff(ScopeId::ROOT);
// dom.hard_diff(ScopeId::ROOT);
// dom.hard_diff(ScopeId::ROOT);
}
#[test]