Skip to content

Commit 9726a06

Browse files
committed
feat: massage lifetimes
1 parent 16dbf4a commit 9726a06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+250
-241
lines changed

README.md

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
Dioxus is a portable, performant, and ergonomic framework for building cross-platform user experiences in Rust.
5050

5151
```rust
52-
static App: FC<()> = |cx, props| {
52+
static App: FC<()> = |(cx, props)| {
5353
let mut count = use_state(cx, || 0);
5454

5555
cx.render(rsx!(
@@ -96,28 +96,6 @@ If you know React, then you already know Dioxus.
9696

9797
See the awesome-dioxus page for a curated list of content in the Dioxus Ecosystem.
9898

99-
<!--
100-
currently commented out until we have more content on the website
101-
## Explore
102-
- [**Fine-grained reactivity**: Skip the diff overhead with signals ](docs/guides/00-index.md)
103-
- [**HTML Templates**: Drop in existing HTML5 templates with html! macro](docs/guides/00-index.md)
104-
- [**RSX Templates**: Clean component design with rsx! macro](docs/guides/00-index.md)
105-
- [**Running the examples**: Explore the vast collection of samples, tutorials, and demos](docs/guides/00-index.md)
106-
- [**Building applications**: Use the Dioxus CLI to build and bundle apps for various platforms](docs/guides/01-ssr.md)
107-
- [**Liveview**: Build custom liveview components that simplify datafetching on all platforms](docs/guides/01-ssr.md)
108-
- [**State management**: Easily add powerful state management that comes integrated with Dioxus Core](docs/guides/01-ssr.md)
109-
- [**Concurrency**: Drop in async where it fits and suspend components until new data is ready](docs/guides/01-ssr.md)
110-
- [**1st party hooks**: Cross-platform router hook](docs/guides/01-ssr.md)
111-
- [**Community hooks**: 3D renderers](docs/guides/01-ssr.md)
112-
## Blog Posts
113-
- [Why we need a stronger typed web]()
114-
- [Isomorphic webapps in 10 minutes]()
115-
- [Rust is high level too]()
116-
- [Eliminating crashes with Rust webapps]()
117-
- [Tailwind for Dioxus]()
118-
- [The monoglot startup]()
119-
-->
120-
12199
## Why?
122100

123101
TypeScript is a great addition to JavaScript, but comes with a lot of tweaking flags, a slight performance hit, and an uneven ecosystem where some of the most important packages are not properly typed. TypeScript provides a lot of great benefits to JS projects, but comes with its own "tax" that can slow down dev teams. Rust can be seen as a step up from TypeScript, supporting:
@@ -130,7 +108,7 @@ TypeScript is a great addition to JavaScript, but comes with a lot of tweaking f
130108
- integrated documentation
131109
- inline built-in unit/integration testing
132110
- best-in-class error handling
133-
- simple and fast build system (compared to webpack!)
111+
- simple and fast build system (compared to WebPack!)
134112
- powerful standard library (no need for lodash or underscore)
135113
- include_str! for integrating html/css/svg templates directly
136114
- various macros (`html!`, `rsx!`) for fast template iteration

docs/src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
```rust, ignore
88
// An example Dioxus app - closely resembles React
9-
static App: FC<()> = |cx, props| {
9+
static App: FC<()> = |(cx, props)| {
1010
let mut count = use_state(cx, || 0);
1111
1212
cx.render(rsx!(

docs/src/concepts/10-concurrent-mode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ async fn ExampleLoader(cx: Context<()>) -> Vnode {
5050
This API stores the result on the Context object, so the loaded data is taken as reference.
5151
*/
5252
let name: &Result<SomeStructure> = use_fetch_data("http://example.com/json", ())
53-
.place_holder(|cx, props|rsx!{<div> "loading..." </div>})
54-
.delayed_place_holder(1000, |cx, props|rsx!{ <div> "still loading..." </div>})
53+
.place_holder(|(cx, props)|rsx!{<div> "loading..." </div>})
54+
.delayed_place_holder(1000, |(cx, props)|rsx!{ <div> "still loading..." </div>})
5555
.await;
5656

5757
match name {

docs/src/concepts/11-arena-memo.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ fn test() -> DomTree {
2121
}
2222
}
2323

24-
static TestComponent: FC<()> = |cx, props|html!{<div>"Hello world"</div>};
24+
static TestComponent: FC<()> = |(cx, props)|html!{<div>"Hello world"</div>};
2525

26-
static TestComponent: FC<()> = |cx, props|{
26+
static TestComponent: FC<()> = |(cx, props)|{
2727
let g = "BLAH";
2828
html! {
2929
<div> "Hello world" </div>
3030
}
3131
};
3232

3333
#[functional_component]
34-
static TestComponent: FC<{ name: String }> = |cx, props|html! { <div> "Hello {name}" </div> };
34+
static TestComponent: FC<{ name: String }> = |(cx, props)|html! { <div> "Hello {name}" </div> };
3535
```
3636

3737
## Why this behavior?

docs/src/concepts/12-signals.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Sometimes you want a signal to propagate across your app, either through far-awa
9696

9797
```rust
9898
const TITLE: Atom<String> = || "".to_string();
99-
const Provider: FC<()> = |cx, props|{
99+
const Provider: FC<()> = |(cx, props)|{
100100
let title = use_signal(&cx, &TITLE);
101101
rsx!(cx, input { value: title })
102102
};
@@ -105,7 +105,7 @@ const Provider: FC<()> = |cx, props|{
105105
If we use the `TITLE` atom in another component, we can cause updates to flow between components without calling render or diffing either component trees:
106106

107107
```rust
108-
const Receiver: FC<()> = |cx, props|{
108+
const Receiver: FC<()> = |(cx, props)|{
109109
let title = use_signal(&cx, &TITLE);
110110
log::info!("This will only be called once!");
111111
rsx!(cx,
@@ -132,7 +132,7 @@ Dioxus automatically understands how to use your signals when mixed with iterato
132132

133133
```rust
134134
const DICT: AtomFamily<String, String> = |_| {};
135-
const List: FC<()> = |cx, props|{
135+
const List: FC<()> = |(cx, props)|{
136136
let dict = use_signal(&cx, &DICT);
137137
cx.render(rsx!(
138138
ul {

docs/src/hello_world.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn main() {
8585
dioxus::desktop::start(App, |c| c);
8686
}
8787

88-
static App: FC<()> = |cx, props| {
88+
static App: FC<()> = |(cx, props)| {
8989
cx.render(rsx! (
9090
div { "Hello, world!" }
9191
))
@@ -111,7 +111,7 @@ fn main() {
111111
Finally, our app. Every component in Dioxus is a function that takes in `Context` and `Props` and returns an `Option<VNode>`.
112112

113113
```rust
114-
static App: FC<()> = |cx, props| {
114+
static App: FC<()> = |(cx, props)| {
115115
cx.render(rsx! {
116116
div { "Hello, world!" }
117117
})
@@ -149,7 +149,7 @@ If we wanted to golf a bit, we can shrink our hello-world even smaller:
149149

150150
```rust
151151
fn main() {
152-
static App: FC<()> = |cx, props| rsx!(cx, div {"hello world!"});
152+
static App: FC<()> = |(cx, props)| rsx!(cx, div {"hello world!"});
153153
dioxus::web::start(App, |c| c);
154154
}
155155
```

examples/async.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async fn main() {
1111
dioxus::desktop::launch(App, |c| c);
1212
}
1313

14-
pub static App: FC<()> = |cx, _| {
14+
pub static App: FC<()> = |(cx, _)| {
1515
let count = use_state(cx, || 0);
1616
let mut direction = use_state(cx, || 1);
1717

examples/borrowed.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ fn main() {
2020
dioxus::desktop::launch(App, |c| c);
2121
}
2222

23-
fn App<'a>(cx: Context<'a>, props: &()) -> DomTree<'a> {
24-
let text: &'a mut Vec<String> = cx.use_hook(|_| vec![String::from("abc=def")], |f| f, |_| {});
23+
fn App((cx, props): Component<()>) -> DomTree {
24+
let text: &mut Vec<String> = cx.use_hook(|_| vec![String::from("abc=def")], |f| f, |_| {});
2525

2626
let first = text.get_mut(0).unwrap();
2727

@@ -43,7 +43,7 @@ impl<'a> Drop for C1Props<'a> {
4343
fn drop(&mut self) {}
4444
}
4545

46-
fn Child1<'a>(cx: Context<'a>, props: &'a C1Props) -> DomTree<'a> {
46+
fn Child1<'a>((cx, props): Component<'a, C1Props>) -> DomTree<'a> {
4747
let (left, right) = props.text.split_once("=").unwrap();
4848

4949
cx.render(rsx! {
@@ -58,13 +58,8 @@ fn Child1<'a>(cx: Context<'a>, props: &'a C1Props) -> DomTree<'a> {
5858
struct C2Props<'a> {
5959
text: &'a str,
6060
}
61-
impl<'a> Drop for C2Props<'a> {
62-
fn drop(&mut self) {
63-
todo!()
64-
}
65-
}
6661

67-
fn Child2<'a>(cx: Context<'a>, props: &'a C2Props) -> DomTree<'a> {
62+
fn Child2<'a>((cx, props): Component<'a, C2Props>) -> DomTree<'a> {
6863
cx.render(rsx! {
6964
Child3 {
7065
text: props.text
@@ -77,7 +72,7 @@ struct C3Props<'a> {
7772
text: &'a str,
7873
}
7974

80-
fn Child3<'a>(cx: Context<'a>, props: &C3Props) -> DomTree<'a> {
75+
fn Child3<'a>((cx, props): Component<'a, C3Props>) -> DomTree<'a> {
8176
cx.render(rsx! {
8277
div { "{props.text}"}
8378
})

examples/calculator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn main() {
1010
dioxus::desktop::launch(APP, |cfg| cfg);
1111
}
1212

13-
const APP: FC<()> = |cx, _| {
13+
const APP: FC<()> = |(cx, _)| {
1414
let cur_val = use_state(cx, || 0.0_f64);
1515
let operator = use_state(cx, || None as Option<&'static str>);
1616
let display_value = use_state(cx, || String::from(""));
@@ -116,7 +116,7 @@ struct CalculatorKeyProps<'a> {
116116
onclick: &'a dyn Fn(MouseEvent),
117117
}
118118

119-
fn CalculatorKey<'a>(cx: Context<'a>, props: &'a CalculatorKeyProps) -> DomTree<'a> {
119+
fn CalculatorKey<'a>((cx, props): Component<'a, CalculatorKeyProps>) -> DomTree<'a> {
120120
rsx!(cx, button {
121121
class: "calculator-key {props.name}"
122122
onclick: {props.onclick}

examples/coroutine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727

2828
use dioxus::prelude::*;
2929

30-
static App: FC<()> = |cx, props| {
30+
static App: FC<()> = |(cx, props)| {
3131
let p1 = use_state(cx, || 0);
3232
let p2 = use_state(cx, || 0);
3333

@@ -59,7 +59,7 @@ struct HorseyProps {
5959
pos: i32,
6060
}
6161

62-
static Horsey: FC<HorseyProps> = |cx, props| {
62+
static Horsey: FC<HorseyProps> = |(cx, props)| {
6363
cx.render(rsx! {
6464
div {
6565
button { "pause" }

0 commit comments

Comments
 (0)