feat: massage lifetimes
This commit is contained in:
1 parent
16dbf4a6f8
commit
9726a065b0
92 files changed
+250
-241
No files matched your search
+1
-1
@@ -11,7 +11,7 @@ async fn main() {
|
||||
dioxus::desktop::launch(App, |c| c);
|
||||
}
|
||||
|
||||
pub static App: FC<()> = |cx, _| {
|
||||
pub static App: FC<()> = |(cx, _)| {
|
||||
let count = use_state(cx, || 0);
|
||||
let mut direction = use_state(cx, || 1);
|
||||
|
||||
|
||||
+5
-10
@@ -20,8 +20,8 @@ fn main() {
|
||||
dioxus::desktop::launch(App, |c| c);
|
||||
}
|
||||
|
||||
fn App<'a>(cx: Context<'a>, props: &()) -> DomTree<'a> {
|
||||
let text: &'a mut Vec<String> = cx.use_hook(|_| vec![String::from("abc=def")], |f| f, |_| {});
|
||||
fn App((cx, props): Component<()>) -> DomTree {
|
||||
let text: &mut Vec<String> = cx.use_hook(|_| vec![String::from("abc=def")], |f| f, |_| {});
|
||||
|
||||
let first = text.get_mut(0).unwrap();
|
||||
|
||||
@@ -43,7 +43,7 @@ impl<'a> Drop for C1Props<'a> {
|
||||
fn drop(&mut self) {}
|
||||
}
|
||||
|
||||
fn Child1<'a>(cx: Context<'a>, props: &'a C1Props) -> DomTree<'a> {
|
||||
fn Child1<'a>((cx, props): Component<'a, C1Props>) -> DomTree<'a> {
|
||||
let (left, right) = props.text.split_once("=").unwrap();
|
||||
|
||||
cx.render(rsx! {
|
||||
@@ -58,13 +58,8 @@ fn Child1<'a>(cx: Context<'a>, props: &'a C1Props) -> DomTree<'a> {
|
||||
struct C2Props<'a> {
|
||||
text: &'a str,
|
||||
}
|
||||
impl<'a> Drop for C2Props<'a> {
|
||||
fn drop(&mut self) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
fn Child2<'a>(cx: Context<'a>, props: &'a C2Props) -> DomTree<'a> {
|
||||
fn Child2<'a>((cx, props): Component<'a, C2Props>) -> DomTree<'a> {
|
||||
cx.render(rsx! {
|
||||
Child3 {
|
||||
text: props.text
|
||||
@@ -77,7 +72,7 @@ struct C3Props<'a> {
|
||||
text: &'a str,
|
||||
}
|
||||
|
||||
fn Child3<'a>(cx: Context<'a>, props: &C3Props) -> DomTree<'a> {
|
||||
fn Child3<'a>((cx, props): Component<'a, C3Props>) -> DomTree<'a> {
|
||||
cx.render(rsx! {
|
||||
div { "{props.text}"}
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ fn main() {
|
||||
dioxus::desktop::launch(APP, |cfg| cfg);
|
||||
}
|
||||
|
||||
const APP: FC<()> = |cx, _| {
|
||||
const APP: FC<()> = |(cx, _)| {
|
||||
let cur_val = use_state(cx, || 0.0_f64);
|
||||
let operator = use_state(cx, || None as Option<&'static str>);
|
||||
let display_value = use_state(cx, || String::from(""));
|
||||
@@ -116,7 +116,7 @@ struct CalculatorKeyProps<'a> {
|
||||
onclick: &'a dyn Fn(MouseEvent),
|
||||
}
|
||||
|
||||
fn CalculatorKey<'a>(cx: Context<'a>, props: &'a CalculatorKeyProps) -> DomTree<'a> {
|
||||
fn CalculatorKey<'a>((cx, props): Component<'a, CalculatorKeyProps>) -> DomTree<'a> {
|
||||
rsx!(cx, button {
|
||||
class: "calculator-key {props.name}"
|
||||
onclick: {props.onclick}
|
||||
|
||||
@@ -27,7 +27,7 @@ fn main() {
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
let p1 = use_state(cx, || 0);
|
||||
let p2 = use_state(cx, || 0);
|
||||
|
||||
@@ -59,7 +59,7 @@ struct HorseyProps {
|
||||
pos: i32,
|
||||
}
|
||||
|
||||
static Horsey: FC<HorseyProps> = |cx, props| {
|
||||
static Horsey: FC<HorseyProps> = |(cx, props)| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
button { "pause" }
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ pub struct Client {
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx, _| {
|
||||
static App: FC<()> = |(cx, _)| {
|
||||
let clients = use_ref(cx, || vec![] as Vec<Client>);
|
||||
let scene = use_state(cx, || Scene::ClientsList);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ fn main() {
|
||||
});
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
let file_manager = use_ref(cx, || Files::new());
|
||||
let files = file_manager.read();
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ fn main() {
|
||||
// We use a special immutable hashmap to make hashmap operations efficient
|
||||
type RowList = im_rc::HashMap<usize, Rc<str>, FxBuildHasher>;
|
||||
|
||||
static App: FC<()> = |cx, _props| {
|
||||
static App: FC<()> = |(cx, _props)| {
|
||||
let items = use_state(cx, || RowList::default());
|
||||
|
||||
let create_rendered_rows = move |from, num| move |_| items.set(create_row_list(from, num));
|
||||
@@ -80,7 +80,7 @@ struct ActionButtonProps<'a> {
|
||||
onclick: &'a dyn Fn(MouseEvent),
|
||||
}
|
||||
|
||||
fn ActionButton<'a>(cx: Context<'a>, props: &'a ActionButtonProps) -> DomTree<'a> {
|
||||
fn ActionButton<'a>((cx, props): Component<'a, ActionButtonProps>) -> DomTree<'a> {
|
||||
rsx!(cx, div { class: "col-sm-6 smallpad"
|
||||
button { class:"btn btn-primary btn-block", r#type: "button", id: "{props.id}", onclick: {props.onclick},
|
||||
"{props.name}"
|
||||
@@ -93,7 +93,7 @@ struct RowProps {
|
||||
row_id: usize,
|
||||
label: Rc<str>,
|
||||
}
|
||||
fn Row<'a>(cx: Context<'a>, props: &'a RowProps) -> DomTree<'a> {
|
||||
fn Row((cx, props): Component<RowProps>) -> DomTree {
|
||||
rsx!(cx, tr {
|
||||
td { class:"col-md-1", "{props.row_id}" }
|
||||
td { class:"col-md-1", onclick: move |_| { /* run onselect */ }
|
||||
|
||||
@@ -19,7 +19,7 @@ fn main() {
|
||||
dioxus::desktop::launch(App, |c| c.with_prerendered(content));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
let mut val = use_state(cx, || 0);
|
||||
|
||||
cx.render(rsx! {
|
||||
|
||||
@@ -36,7 +36,7 @@ fn main() {
|
||||
dioxus_desktop::run(APP, (), |c| c.with_edits(edits));
|
||||
}
|
||||
|
||||
const APP: FC<()> = |cx, _props| {
|
||||
const APP: FC<()> = |(cx, _props)| {
|
||||
rsx!(cx, div {
|
||||
"some app"
|
||||
})
|
||||
|
||||
@@ -31,7 +31,7 @@ fn main() {
|
||||
});
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
let state = use_ref(cx, || Calculator::new());
|
||||
|
||||
let clear_display = state.read().display_value.eq("0");
|
||||
@@ -76,7 +76,7 @@ struct CalculatorKeyProps<'a> {
|
||||
onclick: &'a dyn Fn(MouseEvent),
|
||||
}
|
||||
|
||||
fn CalculatorKey<'a, 'r>(cx: Context<'a>, props: &'a CalculatorKeyProps) -> DomTree<'a> {
|
||||
fn CalculatorKey<'a>((cx, props): Component<'a, CalculatorKeyProps>) -> DomTree<'a> {
|
||||
cx.render(rsx! {
|
||||
button {
|
||||
class: "calculator-key {props.name}"
|
||||
|
||||
@@ -11,7 +11,7 @@ fn main() {
|
||||
dioxus::desktop::launch(App, |c| c);
|
||||
}
|
||||
|
||||
pub static App: FC<()> = |cx, _| {
|
||||
pub static App: FC<()> = |(cx, _)| {
|
||||
let state = use_state(cx, PlayerState::new);
|
||||
|
||||
let is_playing = state.is_playing();
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ fn main() {
|
||||
dioxus::desktop::launch(App, |c| c);
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
let mut count = use_state(cx, || 0);
|
||||
|
||||
cx.render(rsx! {
|
||||
|
||||
@@ -49,7 +49,7 @@ const NONE_ELEMENT: Option<()> = None;
|
||||
use baller::Baller;
|
||||
use dioxus::prelude::*;
|
||||
|
||||
pub static Example: FC<()> = |cx, props| {
|
||||
pub static Example: FC<()> = |(cx, props)| {
|
||||
let formatting = "formatting!";
|
||||
let formatting_tuple = ("a", "b");
|
||||
let lazy_fmt = format_args!("lazily formatted text");
|
||||
@@ -184,7 +184,7 @@ mod baller {
|
||||
pub struct BallerProps {}
|
||||
|
||||
/// This component totally balls
|
||||
pub fn Baller<'a>(cx: Context<'a>, props: &BallerProps) -> DomTree<'a> {
|
||||
pub fn Baller(_: Component<BallerProps>) -> DomTree {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ pub struct TallerProps {
|
||||
}
|
||||
|
||||
/// This component is taller than most :)
|
||||
pub fn Taller<'a>(cx: Context<'a>, props: &'a TallerProps) -> DomTree<'a> {
|
||||
pub fn Taller(_: Component<TallerProps>) -> DomTree {
|
||||
let b = true;
|
||||
todo!()
|
||||
}
|
||||
+1
-1
@@ -9,7 +9,7 @@ fn main() {
|
||||
println!("{}", ssr::render_vdom(&vdom, |c| c));
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
cx.render(rsx!(
|
||||
div {
|
||||
h1 { "Title" }
|
||||
|
||||
@@ -14,7 +14,7 @@ fn main() {
|
||||
|
||||
const STYLE: &str = "body {overflow:hidden;}";
|
||||
|
||||
pub static App: FC<()> = |cx, props| {
|
||||
pub static App: FC<()> = |(cx, props)| {
|
||||
cx.render(rsx!(
|
||||
div { class: "overflow-hidden"
|
||||
style { "{STYLE}" }
|
||||
@@ -30,7 +30,7 @@ pub static App: FC<()> = |cx, props| {
|
||||
))
|
||||
};
|
||||
|
||||
pub static Header: FC<()> = |cx, props| {
|
||||
pub static Header: FC<()> = |(cx, props)| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
header { class: "text-gray-400 bg-gray-900 body-font"
|
||||
@@ -56,7 +56,7 @@ pub static Header: FC<()> = |cx, props| {
|
||||
})
|
||||
};
|
||||
|
||||
pub static Hero: FC<()> = |cx, props| {
|
||||
pub static Hero: FC<()> = |(cx, props)| {
|
||||
//
|
||||
cx.render(rsx! {
|
||||
section{ class: "text-gray-400 bg-gray-900 body-font"
|
||||
@@ -94,7 +94,7 @@ pub static Hero: FC<()> = |cx, props| {
|
||||
}
|
||||
})
|
||||
};
|
||||
pub static Entry: FC<()> = |cx, props| {
|
||||
pub static Entry: FC<()> = |(cx, props)| {
|
||||
//
|
||||
cx.render(rsx! {
|
||||
section{ class: "text-gray-400 bg-gray-900 body-font"
|
||||
@@ -107,7 +107,7 @@ pub static Entry: FC<()> = |cx, props| {
|
||||
})
|
||||
};
|
||||
|
||||
pub static StacksIcon: FC<()> = |cx, props| {
|
||||
pub static StacksIcon: FC<()> = |(cx, props)| {
|
||||
cx.render(rsx!(
|
||||
svg {
|
||||
// xmlns: "http://www.w3.org/2000/svg"
|
||||
@@ -122,7 +122,7 @@ pub static StacksIcon: FC<()> = |cx, props| {
|
||||
}
|
||||
))
|
||||
};
|
||||
pub static RightArrowIcon: FC<()> = |cx, props| {
|
||||
pub static RightArrowIcon: FC<()> = |(cx, props)| {
|
||||
cx.render(rsx!(
|
||||
svg {
|
||||
fill: "none"
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ pub struct TodoItem {
|
||||
}
|
||||
|
||||
const STYLE: &str = include_str!("./assets/todomvc.css");
|
||||
const App: FC<()> = |cx, props| {
|
||||
const App: FC<()> = |(cx, props)| {
|
||||
let draft = use_state(cx, || "".to_string());
|
||||
let todos = use_state(cx, || HashMap::<u32, Rc<TodoItem>>::new());
|
||||
let filter = use_state(cx, || FilterState::All);
|
||||
@@ -85,7 +85,7 @@ pub struct TodoEntryProps {
|
||||
todo: Rc<TodoItem>,
|
||||
}
|
||||
|
||||
pub fn TodoEntry<'a>(cx: Context<'a>, props: &TodoEntryProps) -> DomTree<'a> {
|
||||
pub fn TodoEntry((cx, props): Component<TodoEntryProps>) -> DomTree {
|
||||
let is_editing = use_state(cx, || false);
|
||||
let contents = use_state(cx, || String::from(""));
|
||||
let todo = &props.todo;
|
||||
|
||||
@@ -12,7 +12,7 @@ fn main() {
|
||||
|
||||
const ENDPOINT: &str = "https://api.openweathermap.org/data/2.5/weather";
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
//
|
||||
let body = use_suspense(
|
||||
cx,
|
||||
@@ -38,7 +38,7 @@ static App: FC<()> = |cx, props| {
|
||||
#[derive(PartialEq, Props)]
|
||||
struct WeatherProps {}
|
||||
|
||||
static WeatherDisplay: FC<WeatherProps> = |cx, props| {
|
||||
static WeatherDisplay: FC<WeatherProps> = |(cx, props)| {
|
||||
//
|
||||
cx.render(rsx!(
|
||||
div { class: "flex items-center justify-center flex-col"
|
||||
|
||||
@@ -19,7 +19,7 @@ fn main() {
|
||||
dioxus::web::launch(App, |c| c);
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
let mut rng = SmallRng::from_entropy();
|
||||
let rows = (0..1_000).map(|f| {
|
||||
let label = Label::new(&mut rng);
|
||||
@@ -45,7 +45,7 @@ struct RowProps {
|
||||
row_id: usize,
|
||||
label: Label,
|
||||
}
|
||||
fn Row<'a>(cx: Context<'a>, props: &'a RowProps) -> DomTree<'a> {
|
||||
fn Row((cx, props): Component<RowProps>) -> DomTree {
|
||||
let [adj, col, noun] = props.label.0;
|
||||
cx.render(rsx! {
|
||||
tr {
|
||||
|
||||
@@ -16,7 +16,7 @@ fn main() {
|
||||
dioxus::web::launch(App, |c| c);
|
||||
}
|
||||
|
||||
static App: FC<()> = |cx, props| {
|
||||
static App: FC<()> = |(cx, props)| {
|
||||
let mut count = use_state(cx, || 0);
|
||||
|
||||
cx.render(rsx! {
|
||||
|
||||
Reference in new issue
Block a user